Testing Project

Objectives:

Due: Before class before class on Friday, Oct 25.Staggered Extension: Analysis is due before class on Monday.

Pair Assignment

This is the first pair assignment of the term. Since there are 19 students in the class, I will allow one (and only one) team of three or a single person to work alone. Since I'm not sure that this project is large enough to effectively use three people, I'm only allowing one team of three.

Set up

Download the code for the Car class, which defines a model of a car that can go forward or reverse, using appropriate amounts of fuel. Create a new Car project and add the code for the Car class.

Notice that the Car's methods are stubs--they only contain enough code to make Car compile. I have my own version of this code with real method implementations. However, my code is not perfect and contains faults.

Also notice the class invariants and pre- and post-conditions in the code. They clarify the natural language comments in the code.

Here is the (public) API for the Car class.

Testing

Using JUnit, write test cases for the Car class. Put your tests in a separate package, as we did in class. Since you do not have code for the Car class, you will have to imagine what that code might look like to write good tests. You might find it useful to write code for the Car class if you are having trouble imagining what the code might look like.

Goal: Create a set of good test cases that are likely to find errors in the code. Specifically, you want to be able to reveal the faults in my code. We've been talking about what it means for a test case and/or a set of test cases to be good, e.g., you want to automate the test case, cover all of the code/functionality and you want to test boundary cases, etc..

I'm not giving you the actual code because I don't want you to simply debug my code and write test cases that find those bugs. I want you to write test cases that will reveal ANY and ALL faults in the code.

Enjoy the challenge! How often does a professor ask the students to find and expose their faults?? :)

Analysis (60 pts - Individual)

In a text file or PDF (NOT a doc, docx, odt, or anything else), answer the following questions, clearly and concisely:

Hints and Suggestions

You ask: My advice:
How do I start? First, start early! Read through the code, start thinking about what needs to be done and then use a systematic approach to test everything. Think about the different classifications we talked about in class and implement those. You may want to create a checklist on paper of all the possibilities before you try to code anything. (If you need more help, please come talk with me.)
What do I do when the specification is ambiguous? Make reasonable assumptions and document them in the tests--not the Car class because I use my own Car class.
How many tests should I have? How do I know I'm finished? Ah, that is the tester's dilemma, isn't it? Use a systematic approach to make sure that you have covered all possibilities. Start early so you have time to come back to the project with a fresh mind to see if you may have missed something.
How should I organize my test methods/classes? There are several different ways you could organize your test classes. (Note you CAN have multiple test classes for one "base" class.) You can categorize your tests into classes by functionality; by fixtures, e.g., preconditions or object state; by the set up required for the objects; by all pass or all errors.
How should I name my classes? Name tests clearly and consistently. One suggestion is to name them using the format: functionality_state_expectedresult

Submission

Create a tar file from your project by using Eclipse: Export -> General -> Archive File. Select your project and select the "Save in tar format" option. Put the file in a reasonable location. The file extension should be either tar.gz or tgz.

Copy your tar file into a proj1 directory in (one of) your turnin directory.

Copy your analysis file into a proj1 directory in your turnin directory. (Recall that this piece is individual.)

Grading (6% of Final Grade)

You will be evaluated based on the following criteria: