Last Updated On
Are you familiar with TestNG and want to test your understanding? This post contains 25 useful TestNG multiple-choice questions (quiz) to self-test your knowledge.
1. What is TestNG?
Select the best answer
- A testing framework for java inspired by JUnit
- Programming Language
- Database
- All of the above
2. Who created TestNG?
Choose one option
- Sun microsystems
- Cédric Beust
- Bell labs
- None
3. A more powerful and easier-to-use framework, TestNG framework came ____ JUnit.
Choose one option
- Before
- After
- Alongwith
- None
4. What is meant by NG in TestNG?
Choose one option
- New Generation
- Next Generation
- Name Generation
- No Generation
5. What is TRUE about TestNG?
Choose one option
- With TestNG, you are in complete control of what is happening in the test cases and how they are executed.
- Prior to running test case X, run multiple test cases as a pre-request.
- By utilizing easy annotations, grouping, sequencing, and parametrizing, the TestNG framework eliminates the limitations of the older framework.
- All of the above
6. Unlike Junit, TestNG does not have constraints like ____.
- @beforeclass
- @afterclass
- Both A and B
- None of the above
7. ____ are all supported by TestNG.
- A suite before/after
- A test before/after
- A group of tests before/after
- All of the above
8. In the TestNG framework, test cases can be defined ____ one another.
- Dependently on
- Independently of
- Interdependently on
- Intradependently on
9. TestNG is written in
Choose one option
- Java
- Kotlin
- Python
- None
10. What is/are the feature(s) of TestNG?
Choose one option
- Before and After annotations
- Dependent methods
- Better reporting
- All of the above
11. ____ based files are used to configure TestNG test suites
Choose one option
- HTML
- CSS
- XML
- PHP
12. The test suites are organized and run using the ____ file.
Choose one option
- Testng.html
- Testng.xml
- Testng.php
- Testng.pl
13. A testng.xml file defines ____, and test groups that are used to create test suites.
Choose one option
- Classes
- Methods
- Packages
- All of the above
14. ____ files can be used to pass parameters to test methods.
Choose one option
- DataProviders
- Testng.xml
- Both A and B
- None of the above
15. Which of the following is/are the TestNG Annotation(s)?
Choose one option
- @BeforeSuite
- @AfterSuite
- @BeforeTest
- All of the above
16. All test methods in the suite will be executed before the @____ method runs.
Choose one option
- BeforeSuite
- BeforeClass
- BeforeTest
- BeforeMethod
17. A method with ‘@BeforeMethod’ annotation in a class will execute _____
Choose one option
- Before the first test method in the class executes
- Only once before the execution of the @Test, annotated methods begins
- Before each and every test method in the class i.e., the method with @BeforeMethod annotation will execute for every test method in the class
18. A method with ‘@BeforeTest’ annotation in a class will execute _______
Choose one option
- Before every test method in the class
- Once before the execution of test methods in the class begins
- After every test method in the class
19. After all test methods in a suite have been executed, the @____ annotation will run.
- AfterSuite
- AfterTest
- AfterClass
- AfterMethod
20. A TestNG ____ is a piece of code that comes into play during test execution and controls the flow of the test.
Choose one option
- Groups
- Annotation
- Code
- Tags
21. All test methods in that folder will be executed before the @____ annotated method is executed.
Choose one option
- BeforeClass
- BeforeSuite
- BeforeTest
- BeforeMethod
22. Upon completion of all the test methods of the classes in the folder, the @____ method will be executed.
Choose one option
- AfterSuite
- AfterTest
- AfterClass
- AfterMethod
23. This method is called before the class’s first method is invoked using the @____ annotation.
Choose one option
- BeforeSuite
- BeforeClass
- BeforeTest
- BeforeMethod
24. After all test methods of the current class have been executed, the @____ method will be invoked.
Choose one option
- AfterMethod
- AfterSuite
- AfterClass
- AfterTest
25. Every test method will be run prior to the @____ annotation.
Choose all options
- BeforeMethod
- BeforeTest
- BeforeClass
- BeforeSuite