Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NUnit, xUnit or JUnit

 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of these is best to start ?

NUnit has TestFixtures which I believe JUnit doesn't?
Any other limitations/benefits to consider.
Thanks
regards
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NUnit is for unit testing on .NET. JUnit is primarily for unit testing J2SE programs. xUnit is a collective terms to refer to all JUnit-like tools; there are many! See http://www.xprogramming.com/software.htm.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34681
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, JUnit does have "test fixtures." It just doesn't call it that in the code.
A test fixture is the context the test executes in. The objects are created in a setUp method and available during your test.
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ernest and Jeanne.
regards
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is Juint automated? I dont think after checking an example. Looks like some code is required?
 
Greg Ostravich
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by is JUnit automated?
In the program I used JUnit with, I put JUnit in my Ant build.
Then whenever I did a build, it would compile and test as a part of that build. Is this what you mean?
There are a few different ways to run JUnit.
You can run it through the awt graphical interface (but I don't think anybody uses this anymore) or the swing GUI which I think everybody uses when they use a GUI. When you run the GUI it shows a status bar across the display. When the status bar is done, if it's green it's clean.
If it's red there's a problem. It should tell you the line where your assertion failed.
You can also run your JUnit tests from a textual interface.
You can create reports too from your Ant builds through a junitreport Ant task.
Hope this helped -
Greg
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34681
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradeep,
Yes, code is required. The idea is to get your test cases into code form. However, the boilerplate code is always the same - so cut and paste works great. Eclipse's code generation works well too.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
so cut and paste works great.
Regarding this, I'd like to mention that test code should be kept clean just like the production code. If you don't refactor your test code, think about how difficult it will get to change it after some 2000 tests...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic