TestNG Top 10 Interview Questions with Answers
1. What is the sequence of execution of the annotations in TestNG?
Ans : annotations in order from
Before Suite method
Before Test method
Before Class method
Before Method
After Method
After Class method
After Test method
2. Can you arrange the below <testng.xml> tags from parent to child?
<test>
<suite>
<class>
<methods>
<classes>
Ans : Correct order
<suite>
<test>
<classes>
<class>
<methods>
3. How to run test cases in parallel using TestNG?
Ans : parallel = tests/methods/classes
4. In TestNG I have some test’s Test1-Test2-Test3-Test4- Test5. I want to run my execution order is Test5-Test1-Test3-Test2-Test4. How do you set the execution order?
Ans : By priority
@Test (priority=1) in Test5
@Test (priority=2) in Test1 and continues...
5. If a test method failed, then its dependent method will
Ans : Never execute