Quick revision
The short answer
I would move test data close to the tests: small, explicit cases in code or small versioned files in the repository, with a readable name on every row so reports show which case failed. Wide input spaces would be covered by property-based testing plus a few explicit examples that document behaviour. Business rule tables that domain experts own would be kept separate from technical test data, stored as reviewed files and validated in CI. And I would measure: thousands of near-identical spreadsheet rows add run time without finding defects, so rows that never catch anything get removed.
What to remember
In this answer, we redesigned spreadsheet-driven TestNG tests. We moved data close to the tests as code or small versioned files, gave every row a readable name so failures explain themselves, covered wide input spaces with properties plus a few documenting examples, separated business rule tables owned by domain experts and validated them in CI, and measured run time, defects found and mutation score to remove rows that add time without finding anything.
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.
I would move test data close to the tests: small, explicit cases in code or small versioned files in the repository, with a readable name on every row so reports show which case failed. Wide input spaces would be covered by property-based testing plus a few explicit examples that document behaviour. Business rule tables that domain experts own would be kept separate from technical test data, stored as reviewed files and validated in CI. And I would measure: thousands of near-identical spreadsheet rows add run time without finding defects, so rows that never catch anything get removed.
Why this question is asked
Spreadsheet-driven testing usually starts with good intentions: QA engineers and business analysts can add cases without writing code. Years later the spreadsheets have 20,000 rows, nobody knows which ones matter, the suite takes an hour, and a failure says only that row 14,233 failed. Interviewers ask this design question to see whether we can keep what was valuable, the involvement of domain experts, while fixing speed and readability. In this answer, we will look at why the current design fails, then redesign it in steps: data close to tests, named cases, properties for wide spaces, separate business rule tables, and measuring what the rows are worth.
1Why Large Spreadsheets Make Tests Slow and Unreadable
A TestNG data provider supplies rows of arguments to a test method, and TestNG runs the method once per row. When the rows come from a large spreadsheet, typically read with Apache POI, three problems appear together.
First, intent is hidden. A row such as 37, DE, B2, 0, 1, Y says nothing about why it exists. Is it testing a boundary, a country rule or a bug from 2019? Nobody can tell without asking whoever added it. Second, the data drifts from the code. The spreadsheet lives on a shared drive or is updated separately from the code, so a change to the rules and the change to the expected values are not reviewed together, and the suite fails for reasons unrelated to the code under review. Third, the cost grows silently. Opening a 15 MB workbook can take seconds per class, and 20,000 rows that each call a service turn a test run into an hour. Failures are reported with an index and a list of values, which is very hard to read.
2Keep Data Close to the Test, With Names
The first change is to move test data next to the test. Cases that illustrate behaviour belong in code, in the test class or a small companion class, where a reviewer sees them with the code that needs them. Larger tables go into small CSV or YAML files in src/test/resources, versioned in the same repository and changed in the same pull request as the rule they test.
The second change is to give every row a name. The simplest way in TestNG is to make each row a small record whose toString returns a readable description, because reporters show the parameter values.
Notice how much the name adds. The failure tells us the rule and the case at once, and the list of names reads like a specification. Adding the name as the assertion message makes it appear in the failure text too.
3Use Properties for Wide Input Spaces
Many spreadsheet rows exist because someone tried to cover a wide input space by listing values: every weight from 1 to 50 for every country. That is the job property-based testing does better. We state a property that must hold for all valid inputs, such as heavier parcels never get a cheaper band, or every country in the supported list gets some band, and a tool such as jqwik generates hundreds of inputs, including edge cases, and shrinks any failure to the smallest example.
jqwik runs on the JUnit Platform, and TestNG suites can run on the same platform through its TestNG engine, so both can live in one build during a transition. A property replaces thousands of rows with a few lines, and the explicit named examples stay as documentation of the important cases, such as the boundary at 30 kg.
4Separate Business Rule Tables From Technical Test Data
Some of the spreadsheets contain genuinely valuable knowledge: tables of business rules maintained by domain experts, such as tax rates per region and product type, or the decision table for loan approval. Those should not be thrown away. They should be separated from technical test data and given a clear status.
I would keep such tables as reviewed files in the repository, for example a CSV with one row per rule and a column naming the source of each rule. Domain experts change them through a simple pull request, often from the web interface of the code host, with an engineer reviewing. In CI, a validation step checks the table before any test runs: required columns present, values of the right type and range, names unique, no duplicate keys. A broken table then fails with a clear message such as row 12: rate 1.9 is above 1.0, instead of producing hundreds of confusing test failures.
- Named examples in codethe important cases, readable in reports
- Properties with generated inputswide input spaces, shrunk failures
- Business rule tablesowned by domain experts, reviewed files, validated in CI
- Small technical fixturesversioned next to the tests that use them
4 layers, from the top down. Step through them one at a time.
Each kind of data has its own place and its own owner.
5Measure What the Rows Are Worth
Before deleting anything, we measure. For each data provider we record its row count, its total run time, and how many distinct failures it has caught over the last six months. In a typical spreadsheet suite, a few thousand rows account for most of the run time, and many groups of rows have never failed at all, or always fail together, which means they test the same thing.
Mutation testing helps decide. If we remove 90 percent of the rows in a group and the mutation score of the code under test does not change, those rows were not detecting anything the remaining ones miss. A realistic outcome is going from 20,000 rows and 60 minutes to 400 named examples, a dozen properties and two validated rule tables, running in 6 minutes, with the same or better mutation score. Those numbers are what convince both QA and management that the redesign removed cost, not safety.
| Aspect | Spreadsheet-driven | Redesigned |
|---|---|---|
| Location of data | Shared drive, edited separately | Repository, same pull request |
| Failure report | Row index and raw values | Named case and clear message |
| Wide input spaces | Thousands of listed rows | Properties with generated inputs |
| Business rules | Mixed with technical data | Owned tables, validated in CI |
| Run time (illustrative) | About 60 minutes | About 6 minutes |
6Follow-up questions
How do you keep domain experts involved if the spreadsheets go away?
They keep owning the business rule tables, now as reviewed files they can edit through the code host's web interface, with CI validation giving fast feedback. Many find this better than a spreadsheet, because they can see which tests a change affected and the history of every rule.
What if the rows come from production incidents and nobody dares delete them?
Turn each incident row into a named example that says which incident it reproduces, keep those, and measure the rest. Incident cases are among the most valuable tests, but they are valuable because of the story behind them, which a name preserves and a spreadsheet row does not.
Could we just run the spreadsheet tests in parallel instead?
Parallel rows with parallel = true would cut the run time, but they keep the other problems: hidden intent, drift from the code and unreadable failures. It can be a quick relief while the redesign happens, as long as the tests are thread-safe.
7Conclusion
In this answer, we redesigned spreadsheet-driven TestNG tests. We moved data close to the tests as code or small versioned files, gave every row a readable name so failures explain themselves, covered wide input spaces with properties plus a few documenting examples, separated business rule tables owned by domain experts and validated them in CI, and measured run time, defects found and mutation score to remove rows that add time without finding anything.
Open with
The core problem is that big spreadsheets hide intent and drift away from the code, and they grow without anyone measuring what each row is worth. So I would redesign in a few steps.
Then, if they want more
First, move data next to the tests: the important cases as explicit examples in code, and larger tables as small CSV files in the repository, changed in the same pull request as the rule. Second, every row gets a name.
In TestNG I make each row a small record whose toString is a description like exactly heavy limit, Germany, and I pass it as the assertion message, so a failure explains itself instead of showing row 14,233.
Third, where people listed thousands of values to cover a range, I would use property-based testing instead, stating rules like heavier parcels never get a cheaper band and letting the tool generate inputs and shrink failures, while keeping a few named examples as documentation. Fourth, I would separate real business rule tables, owned by domain experts, from technical test data.
Those tables stay as reviewed files that experts can edit, and CI validates them before tests run. And finally I would measure run time and failures per data provider, and use mutation testing to show that removing redundant rows does not reduce what the tests detect, aiming for something like an hour down to a few minutes.
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 "Teams load test data for TestNG data providers from large spreadsheets maintained by QA....": https://scrivio-interview-library.netlify.app/java/testng/c5a93694a5/