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