• What is Automation Testing - Advantages & Types of Tools
  • What is Selenium IDE, Selenium RC, Selenium WebDriver, Selenium Grid?
  • Selenium IDE, Firebug & Firepath Installation


  • Selenium WebDriver Architecture
  • Selenium Installation
  • Challenges and Limitations of Selenium
  • First Selenium WebDriver Script
  • Working with Firefox Browser
  • Solution - Failed To Launch Browser Using Selenium WebDriver
  • Working with Chrome Browser
  • Working with IE Browser
  • Difference Between FindElement & FindElements
  • Install Firebug, Fire path and other add on for Selenium
  • Locators in Selenium
  • Dynamic Xpath
  • Dynamic CSS
  • Handle drop-downs
  • How to work with file upload
  • Handle Alerts & Popups
  • Handle Multiple Windows
  • Mouse Hover event in Selenium
  • Right Click
  • Double Click
  • Drag and Drop
  • Capture Screenshots in Selenium
  • Parameterization
  • Synchronization
  • Implicit Wait, Explicit Wait and Fluent Wait in Selenium
  • Implicit Waits
  • Explicit WebDriver Waits
  • Fluent Wait In Selenium
  • Apache POI
  • How To Read Data From Excel File
  • How To Write Data In Excel File
  • Database Testing Using MSSQL
  • Database Testing Using MySQL
  • Database Testing Using DB2
  • Handle Ajax Call in Selenium
  • Listeners in Selenium
  • Handling JavaScript in Selenium
  • Stale Element Reference Exception in Selenium
  • Integrate Sikuli with Selenium
  • Headless Browser Testing 
  • Headless Browser Testing using HtmlUnitDriver
  • Headless Browser Testing using PhanthomJSDriver


  • TestNG Installation
  • TestNG Complete Tutorial


  • Extent Reports Introduction
  • Extent Reports Generation
  • Capturing Screenshots & Including In Extent Reports
  • Extent Reports Version 4


  • ANT Build Tool - How To Download & Install
  • Maven Build Tool - How To Download & Install
  • Creating Maven Selenium Project
  • GIT Integration with Selenium
  • Jenkins - How To Download & Install
  • Jenkins - Executing TestNG Scripts
  • Jenkins - Generating Reports After Test Execution
  • Jenkins - Executing Maven Project
  • Create build and Execute build for nightly execution
  • Send Email report based on build Status
  • Selenium Continuous Integration with Jenkins [Selenium – Maven – Git – Jenkins] – Step By Step Guide


  • Running Selenium Tests On BrowserStack
  • Kobiton - Mobile Testing Platform with Real Devices


  • Mobile Testing Platform with Real Devices


  • What is Framework & Types of Framework
  • Page Object Model Design Pattern
  • Data Driven Framework
  • How to explain Test Automation Framework or Selenium Automation Framework Architecture In Interview

  • API Testing:

  • Learn API Testing
  • Postman Tutorial (API Testing with Postman)


  • Test Automation Framework Interview Questions
  • Selenium Interview Questions
  • TestNG Interview Questions
  • Java Interview Questions
  • Python Interview Questions
  • API Testing Interview Questions


  • Automation Tester Resume
  • 30 Most Popular TestNG Interview Questions And Answers

    Most Popular TestNG Interview Questions:

    In this post, we will see TestNG Interview Questions with Answers. Our main focus is on Selenium TestNG Interview Questions and also we write some Selenium Interview Questions too. Before going ahead, let’s see some unavoidable Interview Questions such as What Are The Reasons For Choosing Software Testing As Your Career and Explain Your Selenium Test Automation Framework. I don’t want to take much time of yours but I couldn’t move further without mentioning about this inevitable question in any interview i.e., Tell Me About Yourself. Click on the link to get some idea on how to answer Tell Me About Yourself. So, Let’s move on to the actual post.

    Selenium Quiz

    Don’t miss the following posts:

    Here is a video tutorial “Selenium TestNG Interview Questions And Answers”:

    Please be patient. The video will load in some time.

    If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.

    1. What is TestNG?

    TestNG is a testing framework designed to simplify a broad range of testing needs, from unit testing to integration testing. For more information.

    2. What are the advantages of TestNG?

    1. TestNG provides parallel execution of test methods
    2. It allows to define dependency of one test method over other method
    3. It allows to assign priority to test methods
    4. It allows grouping of test methods into test groups
    5. It has support for parameterizing test cases using @Parameters annotation
    6. It allows data driven testing using @DataProvider annotation
    7. It has different assertions that helps in checking the expected and actual results
    8. Detailed (HTML) reports

    3. What are the annotations available in TestNG?


    Practical Example

    4. Can you arrange the below testng.xml tags from parent to child?

    The correct order of the TestNG tags are as follows

    5. How to create and run testng.xml 

    In TestNG framework, we need to create testng.xml file to create and handle multiple test classes. We do configure our test run, set test dependency, include or exclude any test, method, class or package and set priority etc in the xml file.

    View Complete Post

    6. What is the importance of testng.xml file?

    In a Selenium TestNG project, we use testng.xml file to configure the complete test suite in a single file. Some of the features are as follows.

    • testng.xml file allows to include or exclude the execution of test methods and test groups
    • It allows to pass parameters to the test cases
    • Allows to add group dependencies
    • Allows to add priorities to the test cases
    • Allows to configure parallel execution of test cases
    • Allows to parameterize the test cases

    7. How to pass parameter through testng.xml file to a test case?

    We could define the parameters in the testng.xml file and then reference those parameters in the source files.

    Create a java test class, say, and add a test method say parameterizedTest() to the test class. This method takes a string as input parameter. Add the annotation @Parameters(“browser”) to this method.

    The parameter would be passed a value from testng.xml, which we will see in the next step.

    We could set the parameter using the below syntax in the testng.xml file. 

    Here, name attribute represents the parameter name and value represents the value of that parameter.

    Practical Example

    8. What is TestNG Assert and list out common TestNG Assertions?

    TestNG Asserts help us to verify the condition of the test in the middle of the test run. Based on the TestNG Assertions, we will consider a successful test only if it is completed the test run without throwing any exception.

    Some of the common assertions supported by TestNG are

    • assertEqual(String actual,String expected)
    • assertEqual(String actual,String expected, String message)
    • assertEquals(boolean actual,boolean expected)
    • assertTrue(condition)
    • assertTrue(condition, message)
    • assertFalse(condition)
    • assertFalse(condition, message)

    For Complete Post

    9. What is Soft Assert in TestNG?

    Soft Assert collects errors during @Test. Soft Assert does not throw an exception when an assert fails and would continue with the next step after the assert statement.

    If there is any exception and you want to throw it then you need to use assertAll() method as a last statement in the @Test and test suite again continue with next @Test as it is.

    Practical Example

    10. What is Hard Assert in TestNG?

    Hard Assert throws an AssertException immediately when an assert statement fails and test suite continues with next @Test

    Practical Example

    11. What is exception test in TestNG?

    TestNG gives an option for tracing the Exception handling of code. You can verify whether a code throws the expected exception or not. The expected exception to validate while running the test case is mentioned using the expectedExceptions attribute value along with @Test annotation.

    Practical Example

    12. How to set test case priority in TestNG?

    We use priority attribute to the @Test annotations. In case priority is not set then the test scripts execute in alphabetical order.


    13. What is Parameterized testing in TestNG?

    Parameterized tests allow developers to run the same test over and over again using different values.

    There are two ways to set these parameters:

    14. How can we create data driven framework using TestNG?

    By using @DataProvider annotation,  we can create a Data Driven Framework.

    Practical Example

    15. How to run a group of test cases using TestNG?

    TestNG allows you to perform sophisticated groupings of test methods. Not only can you declare that methods belong to groups, but you can also specify groups that contain other groups. Then TestNG can be invoked and asked to include a certain set of groups (or regular expressions) while excluding another set.  This gives you maximum flexibility in how you partition your tests and doesn’t require you to recompile anything if you want to run two different sets of tests back to back.

    Groups are specified in your testng.xml file and can be found either under the <test> or <suite> tag. Groups specified in the <suite> tag apply to all the <test> tags underneath.

    Practical Example

    TestNG Interview Questions 16 – 33

    16. How to create Group of Groups in TestNG?

    Groups can also include other groups. These groups are called MetaGroups. For example, you might want to define a group all that includes smokeTest and functionalTest. Let’s modify our testng.xml file as follows:

    Practical Example

    17. How to run test cases in parallel using TestNG?

    we can use “parallel” attribute in testng.xml to accomplish parallel test execution in TestNG

    The parallel attribute of suite tag can accept four values:

    tests – All the test cases inside <test> tag of testng.xml file will run parallel
    classes – All the test cases inside a java class will run parallel
    methods – All the methods with @Test annotation will execute parallel
    instances – Test cases in same instance will execute parallel but two methods of two different instances will run in different thread.

    Practical Example

    18. How to exclude a particular test method from a test case execution? 

    By adding the exclude tag in the testng.xml

    19. How to exclude a particular test group from a test case execution? 

    By adding the exclude tag in the testng.xml

    Practical Example

    20. How to disable a test case in TestNG ?

    To disable the test case we use the parameter enabled = false to the @Test annotation.

    21. How to skip a @Test method from execution in TestNG?

    By using throw new SkipException()

    Once SkipException() thrown, remaining part of that test method will not be executed and control will goes directly to next test method execution.

    Practical Example

    22. How to Ignore a test case in TestNG?

    To ignore the test case we use the parameter enabled = false to the @Test annotation.

    Practical Example

    23. How TestNG allows to state dependencies?

    TestNG allows two ways to declare the dependencies.

    Using attributes dependsOnMethods in @Test annotations – Practical Example
    Using attributes dependsOnGroups in @Test annotations – Practical Example

    24. What are the different ways to produce reports for TestNG results?

    TestNG offers two ways to produce a report.

    Listeners implement the interface org.testng.ITestListener and are notified in real time of when a test starts, passes, fails, etc…

    Reporters implement the interface org.testng.IReporter and are notified when all the suites have been run by TestNG. The IReporter instance receives a list of objects that describe the entire test run.

    25. What is the use of @Listener annotation in TestNG?

    TestNG listeners are used to configure reports and logging. One of the most widely used listeners in testNG is ITestListener interface. It has methods like onTestStart, onTestSuccess, onTestFailure, onTestSkipped etc. We should implement this interface creating a listener class of our own. Next we should add the listeners annotation (@Listeners) in the Class which was created.

    Practical Example

    26. How to write regular expression In testng.xml file to search @Test methods containing “smoke” keyword.
    Regular expression to find @Test methods containing keyword “smoke” is as mentioned below.

    27. What is the time unit we specify in test suites and test cases? 
    We specify the time unit in test suites and test cases is in milliseconds.

    28. List out various ways in which TestNG can be invoked?

    TestNG can be invoked in the following ways

    • Using Eclipse IDE
    • Using ant build tool
    • From the command line
    • Using IntelliJ’s IDEA

    29. How To Run TestNG Using Command Prompt?

    Run the TestNG using command prompt

    Open command prompt and use the below code

    30. What is the use of @Test(invocationCount=x)?

    The invocationcount attribute tells how many times TestNG should run a test method

    In this example, the method testCase1 will be invoked ten times

    31. What is the use of @Test(threadPoolSize=x)?

    The threadPoolSize attribute tells to form a thread pool to run the test method through multiple threads.

    Note: This attribute is ignored if invocationCount is not specified

    In this example, the method testCase1 will be invoked from three different threads

    32. What does the test timeout mean in TestNG?

    The maximum number of milliseconds a test case should take.

    In this example, the function testCase1 will be invoked ten times from three different threads. Additionally, a time-out of ten seconds guarantees that none of the threads will block on this thread forever.

    33. What are @Factory and @DataProvider annotation?

    @Factory: A factory will execute all the test methods present inside a test class using a separate instance of the respective class with different set of data.

    @DataProvider: A test method that uses DataProvider will be executed the specific methods multiple number of times based on the data provided by the DataProvider. The test method will be executed using the same instance of the test class to which the test method belongs.

    I would like to conclude this post “TestNG Interview Questions” here.

    Final words, Bookmark this post “TestNG Interview Questions” for future reference. After reading this post “TestNG Interview Questions”, if you find that we missed some important questions, please comment below we would try to include those with answers.

    You could find the following Tutorials useful.

    Here I have hand-picked few posts which will help you to learn more interview related stuff:

    TestNG Interview Questions

    Get our latest blog posts delivered to your inbox

    Subscribe and get popular blog posts about software testing industry.


    6 thoughts on “30 Most Popular TestNG Interview Questions And Answers”

    1. Hi Rajkumar, I want job on Test automation.I already completed my selenium,appium and SOAPUI.So please give reference to me.

    2. Hi Raj Kumar,

      Can you please correct question no.4. You have mentioned Testng tags hierarchy but it’s in valid. structure should be as below


      • There is no issue in that Sreenath


      • Returns an Object

        • RajKumar, great work on the tutorials and interview questions. One correction in the return type of data provider: it is array of object array(2 dimensional array of object)

    Leave a Comment

    Share via
    Copy link
    Powered by Social Snap