Thursday 24 October 2013

Advantages of TestNG over Junit

  1. In Junit we have to declare @BeforeClass and @AfterClass which is a constraint where as in TestNG there is no constraint like this.
  2. Additional Levels of setUp/tearDown level are available in TestNG like @Before/AfterSuite,@Before/AfterTest and @Before/AfterGroup
  3. No Need to extend any class in TestNG.
  4. There is no method name constraint in TestNG as in Junit. You can give any name to the test methods in TestNG
  5. In TestNG we can tell the test that one method is dependent on another method where as in Junit this is not possible. In Junit each test is independent of another test.
  6. Grouping of testcases is available in TestNG where as the same is not available in Junit.
  7. Execution can be done based on Groups. For ex. If you have defined many cases and segregated them by defining 2 groups as Sanity and Regression. Then if you only want to execute the “Sanity” cases then just tell TestNG to execute the “Sanity” and TestNG will automatically execute the cases belonging to the “Sanity” group.
  8. Also using TestNG your selenium testcase execution can be done in parallel.

No comments:

Post a Comment