Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where do I start with test cases?

 
Dex Anderson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 7581
52
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic