NGABannerNew1.png

DETAILED READ SECTION

TestNG Interview Questions and Answers



Question: What is TestNG?

Answer:

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


Question. What are the annotations available in TestNG?

Answer:

@BeforeTest

@AfterTest

@BeforeClass

@AfterClass

@BeforeMethod

@AfterMethod

@BeforeSuite

@AfterSuite

@BeforeGroups

@AfterGroups

@Test


Question: What is TestNG Assert and list out some common Assertions supported by TestNG?

Answer:

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)


Different TestNG Asserts Statements:


a) Assert.assertEqual(String actual,String expected) :

Asserts that two Strings are equal. If they are not, an AssertionError is thrown.

Parameters:

actual – the actual value

expected – the expected value


b) Assert.assertEqual(String actual,String expected, String message) :

Asserts that two Strings are equal. If they are not, an AssertionError, with the given message, is thrown.

Parameters:

actual – the actual value

expected – the expected value

message – the assertion error message