Friday 6 December 2013

Advantages of TestNG over Junit



TestNG is testing framework inspired from most popular JUnit framework used for the Java programming language. The TestNG framework is introduced to overcome the limitations of JUnit framework. Most of the automation users are using this framework because of its advantages & more supported features. Until we have executed selenium test script but not even generated test reports. So using this TestNG framework we will learn how to generate test reports.
TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use, such as:
·         Annotations.
·         Flexible test configuration.
·         Support for data-driven testing (with @DataProvider).
·         Support for parameters.
·         Allows distribution of tests on slave machines.
·         Powerful execution model (no more TestSuite).
·         Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc...).
·         Dependent methods for application server testing.
Advantages of TestNG over Junit:
·         In TestNG Annotations are easy to understand over JUnit.
·         In TestNG there is no constraint like you have to declare @BeforeClass and AfterClass, which is present in JUnit.
·         As method name constraint is present in JUnit, such method name constraint is not present in TestNG and you can specify any test method names.
·         In TestNG enable you to grouping of test cases easily which is not possible in JUnit.
·         TestNG supports following three 3 additional setUp/tearDown level:
·         Before/AfterSuite, Before/AfterTest and Before/AfterGroup.
·         TestNG do not require extend any class.
·         TestNG allows us to define the dependent test cases each test case is independent to other test case.
·         TestNG allows us to execute of test cases based on group. Let’s take a scenario where we have created two set of groups “Regression” & “Sanity”. If we want to execute the test cases under Sanity group then it is possible in TestNG framework.
·         Parallel execution of Selenium test cases is possible in TestNG.

No comments:

Post a Comment