TestNG interview questions — Easy
126 easy-level TestNG questions from our Automation Testing bank, each with the correct answer and an explanation of why it is correct.
This topic slice is available to practise but is not yet part of our indexed set.
What this covers
TestNG appears throughout Automation Testing interviews. At easy level, interviewers are typically checking that you know the fundamentals and can describe them precisely — definitions, defaults, and the basic mechanics. Work through these, then explain your answer out loud; the second part is what interviews actually test.
20 example questions
1. Which of the following best describes assertEquals in TestNG?
- A. Collects assertion failures and reports them at assertAll().
- B. Interface used to automatically retry failed tests.
- C. Injects values defined in testng.xml into a test method.
- D. Soft/hard assertion comparing expected and actual values.correct
Why: assertEquals: Soft/hard assertion comparing expected and actual values.
2. In the context of TestNG, timeOut attribute is best described as:
- A. Runs once after all tests in the suite finish.
- B. Fails a test if it exceeds the given milliseconds.correct
- C. Injects values defined in testng.xml into a test method.
- D. Testng.xml attribute controlling parallel thread pool size.
Why: timeOut attribute: Fails a test if it exceeds the given milliseconds.
3. Which of the following best describes thread-count in TestNG?
- A. Soft/hard assertion comparing expected and actual values.
- B. Injects values defined in testng.xml into a test method.
- C. Testng.xml attribute controlling parallel thread pool size.correct
- D. Skips a test from execution.
Why: thread-count: testng.xml attribute controlling parallel thread pool size.
4. Which of the following best describes IRetryAnalyzer in TestNG?
- A. Soft/hard assertion comparing expected and actual values.
- B. Marks a method as a TestNG test.
- C. Runs once after all tests in the suite finish.
- D. Interface used to automatically retry failed tests.correct
Why: IRetryAnalyzer: Interface used to automatically retry failed tests.
5. Which of the following best describes timeOut attribute in TestNG?
- A. Soft/hard assertion comparing expected and actual values.
- B. Interface used to automatically retry failed tests.
- C. Fails a test if it exceeds the given milliseconds.correct
- D. Injects values defined in testng.xml into a test method.
Why: timeOut attribute: Fails a test if it exceeds the given milliseconds.
6. In TestNG, what does @Parameters do or refer to?
- A. Injects values defined in testng.xml into a test method.correct
- B. Runs once after all tests in the suite finish.
- C. Skips a test from execution.
- D. Fails a test if it exceeds the given milliseconds.
Why: @Parameters: Injects values defined in testng.xml into a test method.
7. Which of the following best describes @Ignore / enabled=false in TestNG?
- A. Interface used to automatically retry failed tests.
- B. Injects values defined in testng.xml into a test method.
- C. Skips a test from execution.correct
- D. Soft/hard assertion comparing expected and actual values.
Why: @Ignore / enabled=false: Skips a test from execution.
8. What is the purpose of thread-count in TestNG?
- A. Skips a test from execution.
- B. Soft/hard assertion comparing expected and actual values.
- C. Testng.xml attribute controlling parallel thread pool size.correct
- D. Collects assertion failures and reports them at assertAll().
Why: thread-count: testng.xml attribute controlling parallel thread pool size.
9. What is the purpose of @Parameters in TestNG?
- A. Runs once after all tests in the suite finish.
- B. Collects assertion failures and reports them at assertAll().
- C. Injects values defined in testng.xml into a test method.correct
- D. Testng.xml attribute controlling parallel thread pool size.
Why: @Parameters: Injects values defined in testng.xml into a test method.
10. What is the purpose of IRetryAnalyzer in TestNG?
- A. Marks a method as a TestNG test.
- B. Runs once after all tests in the suite finish.
- C. Interface used to automatically retry failed tests.correct
- D. Soft/hard assertion comparing expected and actual values.
Why: IRetryAnalyzer: Interface used to automatically retry failed tests.
11. In a QA certification mock exam: TestNG's 'priority' attribute on @Test controls:
- A. Thread count.
- B. The order tests run (lower first).correct
- C. Retry count.
- D. Timeout.
Why: priority orders test methods; lower numbers run first.
12. Which of the following best describes @Parameters in TestNG?
- A. Collects assertion failures and reports them at assertAll().
- B. Fails a test if it exceeds the given milliseconds.
- C. Injects values defined in testng.xml into a test method.correct
- D. Marks a method as a TestNG test.
Why: @Parameters: Injects values defined in testng.xml into a test method.
13. What is the purpose of timeOut attribute in TestNG?
- A. Testng.xml attribute controlling parallel thread pool size.
- B. Marks a method as a TestNG test.
- C. Runs once after all tests in the suite finish.
- D. Fails a test if it exceeds the given milliseconds.correct
Why: timeOut attribute: Fails a test if it exceeds the given milliseconds.
14. In TestNG, what does assertEquals do or refer to?
- A. Soft/hard assertion comparing expected and actual values.correct
- B. Fails a test if it exceeds the given milliseconds.
- C. Marks a method as a TestNG test.
- D. Collects assertion failures and reports them at assertAll().
Why: assertEquals: Soft/hard assertion comparing expected and actual values.
15. Which of the following best describes SoftAssert in TestNG?
- A. Interface used to automatically retry failed tests.
- B. Runs once after all tests in the suite finish.
- C. Skips a test from execution.
- D. Collects assertion failures and reports them at assertAll().correct
Why: SoftAssert: Collects assertion failures and reports them at assertAll().
16. In TestNG, what does thread-count do or refer to?
- A. Marks a method as a TestNG test.
- B. Soft/hard assertion comparing expected and actual values.
- C. Testng.xml attribute controlling parallel thread pool size.correct
- D. Collects assertion failures and reports them at assertAll().
Why: thread-count: testng.xml attribute controlling parallel thread pool size.
17. What is the purpose of assertEquals in TestNG?
- A. Interface used to automatically retry failed tests.
- B. Soft/hard assertion comparing expected and actual values.correct
- C. Marks a method as a TestNG test.
- D. Testng.xml attribute controlling parallel thread pool size.
Why: assertEquals: Soft/hard assertion comparing expected and actual values.
18. In TestNG, what does SoftAssert do or refer to?
- A. Testng.xml attribute controlling parallel thread pool size.
- B. Collects assertion failures and reports them at assertAll().correct
- C. Skips a test from execution.
- D. Fails a test if it exceeds the given milliseconds.
Why: SoftAssert: Collects assertion failures and reports them at assertAll().
19. In TestNG, what does timeOut attribute do or refer to?
- A. Skips a test from execution.
- B. Marks a method as a TestNG test.
- C. Runs once after all tests in the suite finish.
- D. Fails a test if it exceeds the given milliseconds.correct
Why: timeOut attribute: Fails a test if it exceeds the given milliseconds.
20. What is the purpose of SoftAssert in TestNG?
- A. Collects assertion failures and reports them at assertAll().correct
- B. Fails a test if it exceeds the given milliseconds.
- C. Marks a method as a TestNG test.
- D. Interface used to automatically retry failed tests.
Why: SoftAssert: Collects assertion failures and reports them at assertAll().