Testng Interview Questions Level
Testng Interview Questions Level
Question# 1: Can you tell me which unit test framework do you use?
Answer: TestNG
Question# 2: What is TestNG?
Answer: TestNG is a testing framework which is used to make testing activities simpler, effective,
convenient and disciplined.
Question# 3: What does NG mean in TestNG?
Answer: NG stands for ‘Next Generation’. It is the next generation of framework after Junit.
Question# 4: What are the testing processes are testable with TestNG?
Answer: We use TestNG for the broad range of testing processes from Unit testing to Integration
testing.
Question# 5: What are the importance of using TestNG in our automation project?
Answer: We use TestNG for the following benefits:
We define different test activities within annotations
It supports parallel execution of the test cases
TestNG supports default threading in parallel execution
We define dependencies of one test methods/groups over another
TestNG effectively helps to define test groups
It supports priority assignment to the Tests
Parameterizations are easily implemented using @Parameters annotation in TestNG
Data-driven testing is efficiently implemented using @DataProvider annotation in TestNG
Different types of Assertion commands are available to validate the scenarios
We can even run TestNG based Selenium projects from the command prompt
It gives a detailed test report
TestNG supports retry of failed test cases multiple times
We can easily implement listeners through ITestListener
TestNG separately creates an XML file for failed test scenarios
Question# 6: What are different annotations available in TestNG?
Answer: Click here to know details about annotations in TestNG.
Question# 7: How do we run tests created through TestNG?
Answer: We trigger tests through the testng.xml file.
Question# 8: What are the significances of the testng.xml file?
Answer: Followings are the significances of testng.xml file:
All the tests are triggered by testng.xml file
It supports inclusion and exclusion of the tests
Parameters are passed from testng.xml file
It supports the addition of dependency of groups
Parallel execution and thread counts are defined in the testng.xml file
XML creates child XML file for failed tests as testng-failed.xml
Question# 9: Can we run TestNG Selenium project from the command prompt?
Answer: Yes.
Question# 10: What are assertions in TestNG?
Answer: TestNG supports various Assert commands to validate the expected and actual conditions of
the scenarios. Some of the Assert commands in TestNG are as follows:
assertEquals(String actual, String expected)
assertNotEquals(String actual, String expected)
Click here to read more…
TESTNG INTERVIEW QUESTIONS LEVEL- YOUTH
Question# 11: How do we send parameters from a testng.xml file?
Answer: testng.xml support parameterization for @Parameters annotation so we send values from
testng.xml by defining below statement:
1 @Test(expectedExceptions=ArrayIndexOutOfBoundsException.class)
Question# 14: How do we set the execution priority of the tests?
Answer: We use priority keyword along with @Test annotation to set the priority of the test. Below
statement sets the priority of the test:
1 @Test(priority=0)
2
3 public void test1(){
4
5 }
6
7
8
9 @Test(priority=1)
10
11 public void test2(){
12
13 }
Question# 15: What are different techniques to implement parameterization in the Selenium project
with TestNG?
Answer: We achieve parameterization in Selenium with TestNG by following techniques:
Parameterization through @Parameters annotation
Parameterization through @DataProvider annotation
Question# 16: How do we combine tests with same group identifications?
Answer: We use groups keyword to combine tests of the same group. Here is the implementation:
1 <groups>
2 <run>
3 <exclude name=”group1”>
4 <include name=”group2”>
5 </include>
6 </exclude>
7 </run>
8 </groups>
Click here to know more…
Question# 18: How are tests run in parallel in TestNG?
Answer: We use “parallel” keyword to run tests in parallel.
Question# 19: How to starts different threads in parallel in TestNG?
Answer: We give integer value to the keyword “thread-count” in the testng.xml file to start multiple
threads in parallel.
Question# 20: What are parallel attributes in TestNG?
Answer: Parallel keyword has following attributes to trigger tests in parallel:
tests
classes
methods
instances
true
false
Question# 21: How to skip tests at runtime with TestNG?
Answer: We throw SkipExceotion(String message) to skip tests at runtime.
Click here to know more…
Question# 22: Can we ignore some tests with TestNG?
Answer: Yes.
Question# 23: How to ignore tests with TestNG?
Answer: We use the following statement with the @Test annotation to ignore tests with TestNG.
1 @Test(enabled=false)
Question# 24: How to define dependencies with TestNG?
Answer: We use the dependsOnMethods keyword to define dependencies with TestNG.
Click here to read in detail…
1 <listeners>
2 <listener class-name=”Class_Name”/>
3 </listeners>
Question# 31: What are the listeners’ name for logging and reporting in TestNG?
Answer: We implement ITestListener for effective logging and IReporter listeners for custom reporting
in TestNG.
Here is the tutorials link for their implementation:
1 <methods>
2 <include name=”.*regression.*”/>
3 </methods>
Question# 34: What is the time unit to define in test suites?
Answer: milliseconds.
Question# 35: How to run particular test methods multiple times?
Answer: we use the following statement to invoke particular tests for a certain number of times.
1 @Test(invocationCount = 20)
2 public void myTest(){
3
4}
Question# 36: How to run a test method from multiple different threads?
Answer: Following code specifies that myTest() method will be invoked from 5 different threads.
Question# 41: Which version of TestNG have you used in your previous project?
Question# 41: How did you install TestNG in your IDE?
Question# 42: Which IDE did you use for TestNG?
Question# 43: Have you extended your existing testng.xml file with another testng.xml file?
Question# 44: When did TestNG come in picture?
Question# 45: Who developed TestNG?
Question# 46: How is TestNG better than Junit?
Question# 47: What is the folder name generated after the first test run through the testng.xml file?
Question# 48: What is emailable-report in TestNG?
Question# 49: Can we pass a large set of parameters through @Parameters annotation?
Question# 50: How to perform inheritance in the testng.xml file?
These are all about TestNG Interview Questions. You may join our Facebook group for more updates on
Selenium and TestNG. Click below link to know more about TestNG.
TestNG Tutorials
Selenium Interview Questions
ShareShare TweetPin itRedditShare
RELATED POSTS
Avinash Mishra
Avinash Mishra is the author of Inviul blog. He is a software engineer and blogger by choice. He loves to
write blogs, and apart from blogging, he is interested in documentary film making, listening to music,
traveling around the world and philanthropic activities.
LEAVE A REPLY
Sign me up for the newsletter!
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
I consent to my submitted data being collected via this form*
Go
Extent Reports: 5 Lines of code to set up reporting in Selenium
September 29, 2018
Next »
Man Behind Inviul!
Hey there, I am Avinash Mishra, The blogging Engineer from Patna, India.
Writing blogs is my passion so I started writing on different niche. But, Inviul is my soul and I feel more
connected to Selenium and Technologies. Read more about me here…