TestNG Multiple-Choice Questions (MCQs)
Q. What is TestNG?
A programming languageA testing framework for Java
A database management system
A web development framework
Q. What does NG stand for in TestNG?
Next GenerationNew Generation
Not Good
No Guarantee
Q. Which annotation is used to define a test method in TestNG?
@Test@TestMethod
@TestCase
@TestNG
Q. Which of the following is NOT a TestNG annotation?
@BeforeMethod@AfterClass
@BeforeSuite
@StartTest
Q. What is the purpose of @BeforeMethod annotation in TestNG?
It runs before each test method in the current classIt runs before all test methods in the current class
It runs before the test suite
It runs before the test class
Q. How can you specify the order of execution for test methods in TestNG?
By using the @Order annotationBy using the priority attribute in @Test annotation
By naming the methods in alphabetical order
TestNG always executes methods in random order
Q. What is the purpose of groups in TestNG?
To organize test methods into categoriesTo create user groups for access control
To group test results in the report
To define test priorities
Q. How do you disable a test method in TestNG?
By removing the @Test annotationBy using the @Ignore annotation
By setting enabled = false in @Test annotation
By commenting out the method
Q. What is the purpose of the dependsOnMethods attribute in TestNG?
To specify the order of test methodsTo create a dependency between test methods
To group test methods
To define test priorities
Q. What is a data provider in TestNG?
A method that supplies test data to test methodsA class that manages test data
A database connection for test data
An XML file containing test data
Q. How do you specify a timeout for a test method in TestNG?
Using the @Timeout annotationUsing the timeout attribute in @Test annotation
Using a separate configuration file
TestNG doesn't support test timeouts
Q. What is the purpose of the @Parameters annotation in TestNG?
To define method parametersTo pass parameters to test methods from testng.xml
To create global variables
To set test priorities