Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JUnit testing void methods

 
Mark Miranda
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic