File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Testing and the fly likes Where do I start with test cases? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Where do I start with test cases?" Watch "Where do I start with test cases?" New topic

Where do I start with test cases?

Dex Anderson

Joined: Apr 06, 2013
Posts: 2
Hi all,

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?

Thank you!
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

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
| Responsibilities:
| 1. Records scores
| 2. Summarizes scores
| 3. ...
| Collaborators:
| 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.

Junilu - [How to Ask Questions] [How to Answer Questions]
I agree. Here's the link:
subject: Where do I start with test cases?
It's not a secret anymore!