TestNG interview questions — Medium
246 medium-level TestNG questions from our Automation Testing bank, each with the correct answer and an explanation of why it is correct.
What this covers
TestNG appears throughout Automation Testing interviews. At medium level, interviewers are typically checking that you have used it in practice: what you configured, what broke, and how you knew it worked. Work through these, then explain your answer out loud; the second part is what interviews actually test.
1 example questions
1. In TestNG, when does a method annotated @BeforeMethod run?
- A. Once before all tests in the class.
- B. Before each @Test method.correct
- C. Only before the first @Test.
- D. After every @Test.
Why: @BeforeMethod runs before every @Test method; @BeforeClass runs once before any test method in the class.