aspose file tools*
The moose likes Testing and the fly likes NUnit, xUnit or JUnit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "NUnit, xUnit or JUnit" Watch "NUnit, xUnit or JUnit" New topic
Author

NUnit, xUnit or JUnit

HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
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

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31076
    
233

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
Thanks Ernest and Jeanne.
regards
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Is Juint automated? I dont think after checking an example. Looks like some code is required?


Groovy
Greg Ostravich
Ranch Hand

Joined: Jul 11, 2002
Posts: 112
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


Greg Ostravich - SCPJ2
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31076
    
233

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

Joined: Jan 23, 2002
Posts: 11962
    
    5
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...


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NUnit, xUnit or JUnit