Quick revision
The short answer
Letting non-developers define tests through data tables is worth it when the tests check business rules that domain experts own and change often, such as pricing, tax or eligibility tables, and when those experts will really maintain the data. Everywhere else the indirection, weak tooling and hard debugging cost more than they return, and executable specifications written close to the code, with readable names, serve the organisation better.
What to remember
In this answer, we saw that data-driven frameworks separate test logic from test data, and that handing the data to non-developers pays off for rule tables that domain experts own and change often. We counted the costs of indirection, weak tooling, hard debugging and missing ownership, set guard rails of version control, review, validation and named owners, preferred readable executable specifications in code for everything else, and decided to measure defects found against upkeep so we can retire suites that no longer earn their place.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Letting non-developers define tests through data tables is worth it when the tests check business rules that domain experts own and change often, such as pricing, tax or eligibility tables, and when those experts will really maintain the data. Everywhere else the indirection, weak tooling and hard debugging cost more than they return, and executable specifications written close to the code, with readable names, serve the organisation better.
Why this question is asked
Every large company has tried this at least once: a framework where analysts fill in a spreadsheet or a BDD table and the tests run themselves. Sometimes it becomes the most valuable suite in the building, and sometimes it becomes a folder of stale spreadsheets that fail every night and that nobody reads. Interviewers ask this design question at a senior level because the answer shows whether we can weigh a tool against the people and the process around it. In this answer, we will recap what data-driven testing means in TestNG and its cousins, look at the one kind of problem where it really pays off, count what it costs, set the guard rails we would demand, compare it with executable specifications kept in code, and finish with how we would measure whether the investment is still worth it.
1A Quick Recap of Data-Driven Tests
A data-driven test separates the logic of a check from the values it checks. We write the test method once, and a data source feeds it many rows of inputs and expected results. In TestNG, the data source is a data provider: a method annotated with @DataProvider that returns rows, usually as an Object[][] or an Iterator<Object[]>. TestNG calls the test method once per row and reports each call as its own result.
The spreadsheet-driven suite takes this one step further. The rows no longer live in Java code but in an Excel or CSV file that someone outside the team edits, and the data provider simply reads that file. BDD tables, such as the Examples table of a Cucumber Scenario Outline, are the same idea in a different syntax: a business reader writes a table in plain language and glue code turns each row into a test.
Notice that the Java code knows nothing about the actual rules. If the CSV file has 240 rows, TestNG reports 240 results, and an analyst can add the 241st without touching Java.
2Where It Pays Off: Rules That Domain Experts Own
The approach earns its keep when three things are true at once. The behaviour is naturally a table, such as insurance eligibility by age band and region, shipping prices by weight and zone, or tax rates by product category. The people who know the right answers are domain experts, not developers, so a developer who writes the expected values is only copying them from a document anyway. And the table changes often, for example every month when pricing is revised.
In that situation, the data table becomes the specification itself. When an actuary changes a row, the test and the requirement change in the same edit, and a developer who breaks a rule gets a failure that points at the row the expert wrote. We remove a whole step of translation, which is exactly where defects in rule-heavy systems usually come from.
3What It Costs
The first cost is indirection. A failing test now says something like appliesEligibilityRule failed for row 147, and the developer has to open a file in another tool, find the row, and work out whether the code or the data is wrong. The second cost is weak tooling: a spreadsheet has no compiler, no refactoring and no meaningful diff in a pull request, so a renamed column or a number stored as text breaks the suite in ways that are hard to see.
The third cost is debugging. Glue code that turns rows into calls tends to grow its own little language, with keywords like Login, ClickButton and VerifyText, and soon we are maintaining an interpreter that nobody designed. The last and biggest cost is ownership. The business user who wrote the sheet moves to another job, the developers do not feel the tests are theirs, and the suite turns into hundreds of red rows that everybody has learned to ignore.
| Aspect | Pays off when | Hurts when |
|---|---|---|
| Ownership | Domain experts edit and review the table | Nobody owns it after the author leaves |
| Change rate | Rules change monthly or faster | Rules rarely change |
| Shape of behaviour | Naturally a table of inputs and outputs | Flows, UI steps, timing |
| Tooling | Plain CSV in Git, reviewed in pull requests | Binary spreadsheets on a shared drive |
| Debugging | Failure names the row and the rule | Failure points into a keyword interpreter |
4The Guard Rails We Would Require
If we decide to go ahead, the data must be treated like code. The tables live in the same Git repository as the code they test, in a text format such as CSV or YAML, so every change has a diff, a pull request and a reviewer. A CODEOWNERS entry names the business owner of each table, so a pricing change cannot be merged without someone from pricing approving it.
The tables also need validation of their own. Before any rule test runs, a small check reads every table and fails fast on a missing column, a duplicate key, an age band that overlaps another, or a value that does not parse. A broken row then produces one clear message, such as eligibility.csv line 88: age is not a number. Finally, there must be a named person or team who answers for the suite, and a rule that a failing row is either fixed or deleted within a few days, never left red.
5The Usual Better Option: Executable Specifications in Code
For most behaviour, the better choice is to keep the examples in the code repository, written by developers together with the domain expert, and to make them readable enough that the expert can review them. TestNG data providers do this well when the rows live in Java and each row carries a description.
Notice that the first column is a sentence the domain expert can read and check, and the assertion message repeats it, so a failure explains itself. The compiler checks the types, the IDE can jump to the code, and a refactoring updates everything at once. The expert reviews the pull request instead of editing a spreadsheet. We keep most of the benefit of a table and lose most of the cost.
6Measuring Whether the Suite Earns Its Keep
A senior decision does not end with the launch. We would track two numbers for every data-driven suite: how many real defects it caught per quarter, counted as failures that led to a code or data fix before release, and how many hours it cost in upkeep, counted as time spent on failures that turned out to be broken data, broken glue code or obsolete rows.
If a suite caught 12 pricing defects last quarter and cost 20 hours, it is clearly worth it. If it caught none and cost 60 hours, we retire it, or move the few rows that still matter into in-code examples. A review every six months keeps the decision honest.
- Is the behaviour a table of rules?YesNext questionNoKeep tests in code
- Do domain experts own and change it often?YesNext questionNoKeep tests in code
- Will a named owner maintain the data?YesBuild it with guard railsNoKeep tests in code
- Version, review and validate the tablesCSV in Git, CODEOWNERS, schema check
- Does it find defects at a fair upkeep cost?YesKeep itNoRetire or move rows into code
5 steps in order. Play them, or step through them one at a time.
7Follow-up questions
Is Cucumber with Gherkin tables the same thing as a spreadsheet-driven suite?
It is the same idea with better tooling, because feature files are plain text in Git and can be reviewed in pull requests. It carries the same risks, though: the step definitions become glue code that someone must maintain, and if business readers never actually read or write the feature files, we have only added a translation layer. It is worth it under the same conditions, when domain experts really take part.
How do you stop a data table from silently losing coverage?
We validate the table before the tests run and also assert something about its size and shape, for example that every region in the product catalogue appears at least once. A test that checks the table covers all known regions fails when someone deletes rows by accident, which a plain data-driven run would never notice because fewer rows just means fewer passing results.
8Conclusion
In this answer, we saw that data-driven frameworks separate test logic from test data, and that handing the data to non-developers pays off for rule tables that domain experts own and change often. We counted the costs of indirection, weak tooling, hard debugging and missing ownership, set guard rails of version control, review, validation and named owners, preferred readable executable specifications in code for everything else, and decided to measure defects found against upkeep so we can retire suites that no longer earn their place.
Open with
I would say it is worth it in a fairly narrow case: business rules that are naturally a table, owned by domain experts, and changed often, like pricing, tax or eligibility rules.
Then, if they want more
There the table really is the specification, and letting the actuary or the pricing analyst edit it removes a translation step where defects usually come from. Outside that case the costs dominate.
A failing row sends you into another tool, spreadsheets have no compiler or useful diff, keyword-driven glue code grows into an interpreter nobody designed, and the biggest risk is that nobody owns the suite once the author moves on, so it stays red and people learn to ignore it.
If we do it, I treat the data as code: plain CSV or YAML in the same Git repository, changes through pull requests, a CODEOWNERS entry for the business owner, and a validation step that fails fast on a bad row before the rule tests run.
For most behaviour, though, I prefer executable specifications in the code, for example a TestNG data provider in Java where each row starts with a readable sentence that also appears in the assertion message, so the domain expert can review it.
Finally, I would measure each suite: defects it caught per quarter against hours spent on upkeep, and retire it if it mostly costs maintenance.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- JUnit user guide, Mockito documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Data-driven testing frameworks (TestNG data providers, spreadsheet-driven suites, BDD...": https://scrivio-interview-library.netlify.app/java/testng/1a5e55685c/