I'm trying to work my way through some exercises on test cases. I'm having a bit of trouble getting started however.
I have a class diagram (As pictured below), and the exercise calls for me to write 20 test cases for the summariseScores() method in the Quiz class. I've read tutorials on JUnit and test cases, but I don't know where to start. Could someone show me an example of some sort? Or give me a starting point?
There can be a number of starting points. Here are a couple:
Starting point #1: open up an IDE (like Eclipse or NetBeans) and create a new project, create a folder for your main code and another folder for your test code. In the test folder, create a new JUnit test case.
Starting point #2: Grab some index cards and write on it so it looks something like this:
| Class: Quiz
| 1. Records scores
| 2. Summarizes scores
| 3. ...
| 1. Course
| 2. Scoresheet
Then start thinking about different scenarios. For example, what happens when there are no scores? What happens when you have only one score? And so on.