Skip to main content
Test Automation

Data-Driven Testing

Running the same test logic with different sets of input data to verify behavior across many scenarios efficiently.

Full definition

Data-driven testing separates test logic from test data, allowing the same test to run with many different input combinations. Instead of writing separate tests for each scenario, you write one test and feed it different data sets.

Example — testing a login form: Instead of 10 separate tests, one test with a data table: | Email | Password | Expected | |---|---|---| | valid@test.com | validPass | Success | | invalid-email | validPass | Email error | | valid@test.com | short | Password error | | (empty) | validPass | Required error | | valid@test.com | (empty) | Required error |

Data sources:

  • CSV/Excel files
  • JSON files
  • Database queries
  • Test framework parameterization (Jest.each, TestNG @DataProvider)

Benefits:

  • Dramatically reduces test code duplication
  • Easy to add new scenarios (add a row, not a test)
  • Separates 'what to test' from 'how to test'
  • Non-technical stakeholders can add test data

Implementation in Vitest/Jest: ```typescript test.each([ ['valid@test.com', 'validPass', 200], ['invalid', 'validPass', 400], ])('login with %s/%s returns %i', async (email, password, status) => { const res = await login(email, password); expect(res.status).toBe(status); }); ```

Learn more about data-driven testing in practice

Automation track