Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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
 
Die Fledermaus does not fear such a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic