Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Junit query  RSS feed

 
steve low
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys im doing Junit testing and im having a problem. Im using Eclipse which can also allow the Junit to copy the testing in a text doc. but the problem is ive been using if's which is a probelm because to save the Junit test in text document I have to use assertEquals instead of if. but im not sure how i would use it. Can sumone show me an example of how i would use the assertEquals in my current statement below. Thanks aot.

Thanks alot

 
Mark Van Tuyl
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
assert (game.numberOfPlayers >= 2 && game.numberOfPlayers <= 5);
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For JUnit, you'd want to say assertTrue() rather than assert. Otherwise I agree with Mark. There's really no way to do this with assertEquals(). If you do this sort of thing more than once or maybe twice, I'd create a custom assert statement (or two) that can be reused in other tests:

It's a bit more work to put diagnostic info into the error messages, but it's often worth it, in my opinion.
[ October 17, 2006: Message edited by: Jim Yingst ]
 
steve low
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys


got it working

tats helped me alot
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!