TestNG Interview Questions
TestNG Interview Questions
Q) Why you have used TestNG in your framework? Can you compare
JUNIT with TestNG framework? (Wipro,Cybage, Avaya, Teito)
Ans:-
Compare to JUnit annotations, TestNG are easy to understand
Unlike JUnit, TestNG does not require to declare @BeforeClass and
@AfterClass
Method name constraint is not there in TestNG
TestNG allows you the grouping of test cases easily which is not
possible in JUnit
TestNG supports following three additional setup: @Before/AfterSuite,
@Before/AfterTest and @Before/AfterGroup
TestNG does not need to extend any class
In TestNG, it is possible to run selenium test cases in parallel
Based on group TestNG allows you to execute the test cases
TestNG allows you to determine the dependent test cases; each test
case is autonomous to other test case
@AfterClass
@BeforeMethod
@AfterMethod
}
@Test(groups="Regression")
public void testCaseFour(){
System.out.println("Im in testCaseFour - And in Regression
Group");
}
}
The below is the XML file to execute, the test methods with group.
We will execute the group “Regression” which will execute the test
methods which are defined with group as “Regression”