Objective: To think abstractly about how a piece of software might be implemented, to gain experience with class invariants and method pre- and post-conditions, to practice writing good tests, and to get experience using JUnit framework.
Due: Before class on Friday, Oct 24.
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 methods are stubs-–they only contain enough code to make Car compilable. I have my own version of this code with real method bodies. However, my code is not perfect and actually contains bugs. Also notice the class invariants and pre- and post-conditions in the code. They clarify the natural language comments in the code.
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 uncover 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 cover all of the code (but you don't have the code) and you want to test boundary cases.
I'm not giving you the actual code because I don't want you to find the bugs in my code and write test cases that find those bugs. I want you to write test cases that will reveal bugs in the code.
Create a jar file from your project.
Copy your jar file into a proj1
directory in your turnin
directory.
You will be evaluated based on the following criteria: