# Data-driven testing

> Data-Driven Testing: What It Is and When It Pays Off. Canonical page: <https://zapple.tech/glossary/data-driven-testing/>

Data-driven testing runs one test over many sets of input and expected values kept apart from the test logic. You write the check once and add cases as rows of data. It pays off when one flow must work for many inputs, such as prices, locales or user roles, and it is overkill for a handful of cases.

## How does data-driven testing compare with keyword-driven and behavior-driven testing?

They answer different questions. Data-driven testing varies the values. Keyword-driven testing varies the steps. Behavior-driven testing varies who can read and write the case.

| | Data-driven | Keyword-driven | Behavior-driven |
|:--|:--|:--|:--|
| What varies | The input and expected values | The sequence of named actions | The scenario, written in plain language |
| Who can add a case | Anyone who can edit a data row | Anyone who knows the keywords | Business and QA, if they share the language |
| Maintenance cost | Low for the data, one place for the logic | The keyword library needs an owner | The step wording needs an owner |
| Where it misleads | Many rows can hide one weak check | A sprawling library nobody trusts | Scenarios nobody reads |

The last three rows are our judgement from practice.

The [Robot Framework user guide](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html) describes all three. Of the data-driven style it says the approach is "very useful when there is a need to test the same scenario with different input and/or output data." Workflow tests in its keyword-driven style are "constructed from several keywords and their possible arguments." Our explainer on [behavior-driven development](/blog/types-of-automation-testing/what-is-behaviour-driven-development/) covers the third.

## When does data-driven testing pay off, and when is it overkill?

It pays off when one flow must hold for many inputs. Think of a price calculation across tax rules, a form across locales, or one screen across user roles. Writing a test per case would repeat the logic and multiply the upkeep.

Common test tools support it out of the box. The [Playwright documentation](https://playwright.dev/docs/test-parameterize) says you can parameterize tests on a test level or on a project level. [pytest](https://docs.pytest.org/en/stable/how-to/parametrize.html) states that its parametrize marker "allows one to define multiple sets of arguments and fixtures at the test function or class." The [JUnit User Guide](https://docs.junit.org/6.1.3/writing-tests/parameterized-classes-and-tests.html) says parameterized tests "make it possible to run a test method multiple times with different arguments." In Cucumber, the [Scenario Outline keyword](https://cucumber.io/docs/gherkin/reference/) "can be used to run the same Scenario multiple times, with different combinations of values."

It is overkill when you have three or four cases. A table adds a file to maintain and a layer of indirection for little gain. It is also the wrong tool when cases differ in steps, not values, because forcing them into one table makes the test logic full of conditions. In both cases, write plain tests. If the suite structure itself needs rework, see our [custom framework development](/services/custom-framework-development/) service. For the wider choice, see how to [build a test automation strategy](/blog/test-automation-frameworks/how-to-build-a-test-automation-strategy/) and [five strategy mistakes to avoid](/blog/test-automation-frameworks/what-is-the-best-test-automation-strategy-5-mistakes-to-avoid/).

## What goes wrong with data-driven suites?

These are practitioner judgement, not measurements.

- **One failing row hides in a long run.** A report that says "test failed" without the row that failed wastes the time the table was meant to save. Insist that each row reports under its own name.
- **Data files nobody owns.** Rows go stale when the product changes. Name an owner for each file and review it like code.
- **Slow suites.** Hundreds of rows through a browser take hours. Run wide tables at the API level, where each row is cheap. See [API test automation](/blog/types-of-automation-testing/what-is-api-test-automation/).
- **Rows that test the same thing.** Many near-identical values add run time, not coverage. Choose values by boundary and rule, not by volume.

Where the data comes from is a separate subject. A table in the repository is the simplest start. Our [tool comparison](/blog/types-of-automation-testing/list-of-the-best-unit-automation-testing-tools/) covers the unit test tools you would run it with.

## What does Zapple.Tech do about it?

If you are not sure whether your suite needs data-driven tests, start with the evidence. Zapple.Tech starts with a one-week QA audit of one product area. It looks at its tests, pipeline and release process, and ends in a written report on what is at risk and what to fix first, plus a pilot plan you can run with Zapple.Tech or without it. Read more on the [QA audit and assessment](/services/audit-and-assessment/) page.

Tell us about your suite in the form below.

## FAQ

### What is data-driven testing?

Data-driven testing is a way of writing automated tests in which one test logic runs over many rows of input and expected results kept separate from the code. Adding a case means adding a row, not writing a new test. It suits flows where the steps stay the same and only the values change.

### What is the difference between data-driven and keyword-driven testing?

Data-driven testing varies the values and keeps the steps fixed. Keyword-driven testing builds each test from named actions, so the steps themselves can differ between tests. The two combine well, with a keyword-built flow run over a table of data.

### What is the difference between data-driven testing and behavior-driven development?

Behavior-driven development is a way of agreeing and writing down expected behavior in plain language, usually as given, when, then scenarios. Data-driven testing is a way of running one test over many values. A scenario template in a behavior-driven tool is one place where the two meet.

### Where should the test data for data-driven tests live?

Keep it in your repository, next to the tests, in a plain format a reviewer can read, such as a table file. Give each file an owner. Data from production or a shared database makes results change without a code change, so use it only with a clear refresh process.

## Sources

- [Playwright documentation, Parameterize tests (current docs)](https://playwright.dev/docs/test-parameterize)
- [pytest documentation, How to parametrize fixtures and test functions (current docs)](https://docs.pytest.org/en/stable/how-to/parametrize.html)
- [JUnit User Guide, Parameterized Classes and Tests (6.1.3)](https://docs.junit.org/6.1.3/writing-tests/parameterized-classes-and-tests.html)
- [Robot Framework User Guide, Different test case styles (current docs)](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html)
- [Cucumber documentation, Gherkin reference: Scenario Outline (current docs)](https://cucumber.io/docs/gherkin/reference/)
