TestNG Interview Questions and Answers | Top 31+ TestNG Interview Questions

TestNG is a testing framework for the Java programming language created by Cédric Beust and inspired by JUnit and NUnit. The design goal of TestNG is to cover a wider range of test categories: unit, functional, end-to-end, integration, etc., with more powerful and easy-to-use functionalities.

Question #1 :What is TestNG?

TestNG is a testing framework for the Java programming language created by Cédric Beust and inspired by JUnit and NUnit. The design goal of TestNG is to cover a wider range of test categories: unit, functional, end-to-end, integration, etc., with more powerful and easy-to-use functionalities

Question #2 : Advantages of TestNG?

Question #3 : Annotations of TestNG?

  • @BeforeTest
  • @AfterTest
  • @BeforeClass
  • @AfterClass
  • @BeforeMethod
  • @AfterMethod
  • @BeforeSuite
  • @AfterSuite
  • @BeforeGroups
  • @AfterGroups
  • @Test

Question #4 :  What is Testng.xml file?

 

  • 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

Question #5 :  How to Pass Parameter Through Testng.xml File to a Test Case?

 

<parameter name=”browser” value=”firefox”/>

Question # 6:  List some TestNG Assert and list out common TestNG Assertions

  • 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)

Question # 7:   What is Soft Assert in TestNG?

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

Question # 8:   What is Hard Assert in TestNG?

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

 

Question # 9:  How to create Group of Groups in TestNG?

Question # 10:  How to set test case priority in TestNG?

 

 

 

Leave a Comment


This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Shares
Share
Tweet
Pin