Quality Testing

Quality is delighting customers

Hi All,

Please let me know which one is better TestNG or JUnit,Since I am beginner which one I have to choose..

-As I study right now JUnit is mostly used in industries,but TestNG having more features than JUnit...

Looking for your feedback!


Views: 493

Reply to This

Replies to This Discussion

Hi Vikrant,

TestNG and JUnit both are Unit testing framework. It is very true that TestNG has got more features than JUnit in terms of writing flexible automation scripts. But, JUnit is more popular than TestNG in terms of learning, ease of using it. I also work in Selenium since last 6 months and most of the cases i used JUnit as Unit testing framework. 

As you are a beginner so it is always better to start with something which is easy to learn and apply hence for now you can choose JUnit as your Unit testing framework. But, i would suggest not to restrict knowledge to only JUnit or TestNG. It is always better to have a knowledge of both. As time goes you can also put your hands on TestNG.

Thanks and regards


thanks a lot Sitam for this valuable guidance!

Very ture, dear first I have to do with JUnit, So that I can feel the difference practically between them.

Like that-What are the advance features in TextNG, how it is more flexible than JUnit.

Thanks a lot!



testNG provides support for "Group Test" and "Dependency Test" through its enriched unit testing framework. But in case of JUnit, support is not there. Consider the following scenario for testing :-

We want to execute a test (nextTest) if and only if the test (currentTest) before it is executed successfully. Means execution of the next test is totally dependent on the previous one. 

In TestNG code will look like the following :-

public void currentTest()
System.out.println("This is Current Test");

public void nextTest()
System.out.println("This is Next Test");

But, in JUnit there is no support for "Dependency Test" therefore the mentioned scenario can not be achieved.

Hope this will answer your question. Any further discussion is appreciated.

Thanks and regards

Testng is better than Junit.There are lot of features testNg got compared to Junit.

If you need to know more let me know.

Thanks Riyazul,

sure I will contact you soon!


TTWT Magazine





© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service