• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Junit query

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
assert (game.numberOfPlayers >= 2 && game.numberOfPlayers <= 5);
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys


got it working

tats helped me alot
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic