Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawbacks of TestNG compared to jUnit? [closed]

Tags:

junit

testng

I'm familiar with jUnit, and heard TestNG might be a solution to some of jUnit's annoyences - e.g. its insistence to create a separate instance of the test class per test, thus forcing me to use static field for objects I want to reuse between tests.

(Let's say you agree with me that this is a drawback, and not turn this question to something it's not)

What I'm asking here, is what drawbacks does TestNG have, compared to jUnit? Why not use TestNG, assuming this is a new project and there isn't any migration cost?

like image 885
ripper234 Avatar asked Nov 23 '10 20:11

ripper234


People also ask

Why do you use TestNG And why not JUnit?

JUnit does not include any dependency tests. TestNG includes dependency tests. JUnit is a framework that is open-source and may be used to write and trigger tests. TestNG is a Java-based framework that provides an improved way to run tests.

Why JUnit is preferred over TestNG?

Key Difference between TestNG and JUnitTestNG allows us to create parallel tests, whereas JUnit does not support running parallel tests. In TestNG, Test cases can be grouped together, while in JUnit, Grouping tests together is not possible.

How is TestNG better than JUnit?

TestNG is a Java-based test automation framework that was inspired by JUnit. It overcomes all the limitations of JUnit along with additional functionalities. This makes it more powerful and easier to use.


2 Answers

I'm the creator of TestNG. I'm not going to weigh in since I'm obviously biased, but I'm happy to answer any question you might have about TestNG.

Andy: thanks for your comment. FYI (you probably already know that but maybe the original poster doesn't), there is a TestNG Eclipse plug-in (which I develop in parallel to TestNG).

like image 192
Cedric Beust Avatar answered Nov 10 '22 03:11

Cedric Beust


I personally have not encountered any significant drawbacks compared to JUnit.

At the start of a new project, my team switched to TestNG and had no regrets. TestNG is more powerful and supports broader usage than unit tests.

Some tools support JUnit but not TestNG. These are tools that I have not yet needed. For example:

  • Google's CodePro Analytix supports generation of JUnit unit tests.
  • The Eclipse IDE for RCP development supports run/debug configurations for "JUnit plug-in tests."
like image 41
Andy Thomas Avatar answered Nov 10 '22 02:11

Andy Thomas