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. In the context of TestNG, IRetryAnalyzer is best described as:
- A. Collects assertion failures and reports them at assertAll().
- B. Interface used to automatically retry failed tests.correct
- C. Marks a method as a TestNG test.
- D. Runs once after all tests in the suite finish.
Why: IRetryAnalyzer: Interface used to automatically retry failed tests.
2. Which of the following best describes IRetryAnalyzer in TestNG?
- A. Injects values defined in testng.xml into a test method.
- B. Runs once after all tests in the suite finish.
- C. Collects assertion failures and reports them at assertAll().
- D. Interface used to automatically retry failed tests.correct
Why: IRetryAnalyzer: Interface used to automatically retry failed tests.
3. Which of the following best describes thread-count in TestNG?
- A. Skips a test from execution.
- B. Testng.xml attribute controlling parallel thread pool size.correct
- C. Injects values defined in testng.xml into a test method.
- D. Fails a test if it exceeds the given milliseconds.
Why: thread-count: testng.xml attribute controlling parallel thread pool size.
4. 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.
5. Which of the following best describes assertEquals in TestNG?
- A. Runs once after all tests in the suite finish.
- B. Soft/hard assertion comparing expected and actual values.correct
- C. Collects assertion failures and reports them at assertAll().
- D. Marks a method as a TestNG test.
Why: assertEquals: Soft/hard assertion comparing expected and actual values.
6. 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.
7. 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.
8. What is the purpose of thread-count in TestNG?
- A. Marks a method as a TestNG test.
- B. Testng.xml attribute controlling parallel thread pool size.correct
- C. Interface used to automatically retry failed tests.
- D. Collects assertion failures and reports them at assertAll().
Why: thread-count: testng.xml attribute controlling parallel thread pool size.
9. Which of the following best describes @Parameters in TestNG?
- A. Collects assertion failures and reports them at assertAll().
- B. Runs once after all tests in the suite finish.
- C. Interface used to automatically retry failed tests.
- D. Injects values defined in testng.xml into a test method.correct
Why: @Parameters: Injects values defined in testng.xml into a test method.
10. In TestNG, what does assertEquals do or refer to?
- A. Interface used to automatically retry failed tests.
- B. Injects values defined in testng.xml into a test method.
- C. Collects assertion failures and reports them at assertAll().
- D. Soft/hard assertion comparing expected and actual values.correct
Why: assertEquals: Soft/hard assertion comparing expected and actual values.
11. In TestNG, what does @Parameters do or refer to?
- A. Soft/hard assertion comparing expected and actual values.
- B. Interface used to automatically retry failed tests.
- C. Injects values defined in testng.xml into a test method.correct
- D. Runs once after all tests in the suite finish.
Why: @Parameters: Injects values defined in testng.xml into a test method.
12. 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().
13. 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().
14. In TestNG, what does thread-count do or refer to?
- A. Marks a method as a TestNG test.
- B. Testng.xml attribute controlling parallel thread pool size.correct
- C. Injects values defined in testng.xml into a test method.
- D. Skips a test from execution.
Why: thread-count: testng.xml attribute controlling parallel thread pool size.
15. What is the purpose of IRetryAnalyzer in TestNG?
- A. Testng.xml attribute controlling parallel thread pool size.
- B. Skips a test from execution.
- C. Interface used to automatically retry failed tests.correct
- D. Marks a method as a TestNG test.
Why: IRetryAnalyzer: Interface used to automatically retry failed tests.
16. In TestNG, what does timeOut attribute do or refer to?
- A. Fails a test if it exceeds the given milliseconds.correct
- B. Soft/hard assertion comparing expected and actual values.
- C. Marks a method as a TestNG test.
- D. Runs once after all tests in the suite finish.
Why: timeOut attribute: Fails a test if it exceeds the given milliseconds.
17. Which of the following best describes SoftAssert in TestNG?
- A. Collects assertion failures and reports them at assertAll().correct
- B. Fails a test if it exceeds the given milliseconds.
- C. Soft/hard assertion comparing expected and actual values.
- D. Interface used to automatically retry failed tests.
Why: SoftAssert: Collects assertion failures and reports them at assertAll().
18. During a sprint demo, a teammate asks: 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.
19. Which of the following best describes @Ignore / enabled=false in TestNG?
- A. Marks a method as a TestNG test.
- B. Interface used to automatically retry failed tests.
- C. Soft/hard assertion comparing expected and actual values.
- D. Skips a test from execution.correct
Why: @Ignore / enabled=false: Skips a test from execution.
20. In TestNG, what does IRetryAnalyzer do or refer to?
- A. Injects values defined in testng.xml into a test method.
- B. Soft/hard assertion comparing expected and actual values.
- C. Interface used to automatically retry failed tests.correct
- D. Skips a test from execution.
Why: IRetryAnalyzer: Interface used to automatically retry failed tests.