This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JUNIT test fail message

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to test HelloWorld2 class:


Following is the code of my HelloWorld2Test class:





I am getting the error message.


But If I comment both the fail statements i.e.



the test fail message shown in the image vanishes.

Please guide me is it fine to comment the fail statements shown in the above code?


Zulfi.
Testing-Hello-World2-class.jpg
[Thumbnail for Testing-Hello-World2-class.jpg]
 
Saloon Keeper
Posts: 12133
258
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The fail() method is just there to make sure you don't forget to implement your test methods.

Don't just comment them out, remove them completely. Unused code should not remain in your source files. If you want to keep code around for future use, use a versioning system.
 
Zulfi Khan
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for your advise. I would use a not condition with fail method.

I would try to learn versioning in NetBeans.

Zulfi.
 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest you also learn git (a versioning application) from the command line.  There are things that integrate well into an IDE and thing that don't.  The book Pro Git is available in its entirety here.
 
Zulfi Khan
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for this great gift.

God bless you with more skills.


Zulfi.
 
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic