wood burning stoves 2.0*
The moose likes Testing and the fly likes JUnit testing void methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "JUnit testing void methods" Watch "JUnit testing void methods" New topic
Author

JUnit testing void methods

Mark Miranda
Greenhorn

Joined: Feb 25, 2011
Posts: 24
Hello,

How can I write JUnit test cases for the Class below?

I put something together quickly, but that's basically the skeleton for the program i'm going to write...


I'm still fairly new to JUnit

Pawel Piwowar
Greenhorn

Joined: Feb 12, 2010
Posts: 21
Hello,

Your findCar() method must return something, should not be void.
Since you fix this, the class could be tested with code like that:




You can create similar tests for other methods.
Repeating code, like creating new instance of ParkingLot could be moved to separate method annotated with @Before


SCJP 5, SCWCD 1.4, SCBCD 5, SCEA part1
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JUnit testing void methods
 
Similar Threads
Usefulness of assigning an object to an interface reference variable?
Help with ArrayList error
One to One mapping in Hibernate 3
Exception "javax.persistence.EntityNotFoundException: Unable to find ParkingSpace with 3