Skip to content

TestNG & Frameworks Interview Questions for Automation Testing

7 TestNG & Frameworks questions with answers for automation testing roles. Tick what you have solved to track your progress.

Sheet progressStart practicing
04

How would you design an automation framework from scratch?

Show answer
Maven project → POM with a BasePage → driver factory with ThreadLocal → config files → data-driven utilities (Excel/JSON) → TestNG or Cucumber runner → logging → Extent reports with screenshots on failure → Jenkins pipeline.
05

How do you take a screenshot on failure in TestNG?

Show answer
Implement ITestListener.onTestFailure(): File src = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); then copy it into the reports folder.
06

What is a DataProvider in TestNG?

Show answer
@DataProvider returns Object[][]; a @Test(dataProvider = "name") method runs once per row — the basis of data-driven tests, often reading Excel or JSON.
07

How do you decide what to automate?

Show answer
Automate stable, repetitive, high-risk and data-heavy flows (smoke, regression). Skip one-time tests, frequently changing UI and checks needing human judgement. Compare run frequency × manual time with build and maintenance cost.