This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cross reference (function) Junit test

 
Adrien Ruffie
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all, my problem is:

I have two functions in my class which I would like to test, start(), isRunning()

But for the function which test start() method I use isRunning() to validate my test,
and for the function which test isRunning() methid I use start() too.

example:

@Test
public void testStart() {
assertFalse(server.isRunning());

server.start();

assertTrue(server.isRunning());
}

Do you have an idea for best pratice and how to test cross reference in unit test ?

Thank all
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your test is fine. It is ok to call two methods in the same test when they are testing a scenario as yours is.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic