Modules
Intermediate⏱ 7 min read

Test Data Generation

sign in to track

Test data is the input used during software testing to verify how an application behaves under different conditions. Good test data helps testers validate normal scenarios, invalid inputs, boundary conditions, and unusual situations.

Poorly designed test data can lead to shallow testing, missed edge cases, and false confidence in software quality. Therefore, test data design is an important part of effective test case design.

Types of Test Data

1. Valid Test Data

Data that follows the expected rules and should be accepted by the system.

Example:

  • Valid email: user@example.com

  • Valid age: 25

  • Valid password: Test@123

2. Invalid Test Data

Data that violates the expected rules and should be rejected appropriately.

Example:

  • Invalid email: user@

  • Age: -5

  • Incorrect password format

3. Boundary Test Data

Data that tests the limits of an input field or business rule.

For example, if age must be between 18 and 60:

  • 17 → Invalid

  • 18 → Valid boundary

  • 19 → Valid

  • 59 → Valid

  • 60 → Valid boundary

  • 61 → Invalid

4. Empty or Missing Data

Used to verify how the system behaves when required information is not provided.

Example:

  • Empty username

  • Empty password

  • Missing required form field

5. Special or Unexpected Data

Used to check how the system handles unusual inputs.

Example:

  • Special characters: @#$%^&*

  • Very long text

  • Unicode characters

  • Leading/trailing spaces

  • Duplicate values

6. Realistic Test Data

Data that represents realistic user or business scenarios.

Example:
For an e-commerce application:

  • Different customer profiles

  • Different products

  • Multiple addresses

  • Different order quantities

  • Different payment scenarios

Test Data Design Techniques

Testers can use techniques such as:

  • Equivalence Partitioning — divide input into valid and invalid groups and test representative values.

  • Boundary Value Analysis — test values at, just below, and just above limits.

  • Decision Table Testing — create data combinations based on different business conditions.

  • Pairwise Testing — select combinations that efficiently cover interactions between multiple input parameters.

  • Negative Testing — intentionally provide invalid or unexpected data.

Example: Password Test Data

Suppose a system requires a password between 8 and 20 characters.

Useful test data could include:

  • Password1 → Valid

  • Pass123 → Invalid, below minimum

  • 12345678 → Valid length

  • 12345678901234567890 → Valid boundary

  • 123456789012345678901 → Invalid, above maximum

  • Empty password → Invalid

  • Password containing special characters → Verify according to requirements

  • Password containing spaces → Verify according to requirements

Good Test Data Practices

  • Cover both positive and negative scenarios.

  • Include boundary and edge-case values.

  • Use realistic data where appropriate.

  • Avoid using only ideal or normal inputs.

  • Keep test data organized and reusable.

  • Ensure sensitive or production data is protected.

  • Reset or clean up data when necessary.

  • Document important data dependencies.

  • Generate different datasets when testing different scenarios.

◈Key Points

  • Categories: valid data, invalid data, boundary values, null/empty, special characters, large volumes.
  • Never use production data for testing without anonymisation — it's a security and compliance risk.
  • Data factories and Faker libraries (Faker.js, Python Faker) generate realistic synthetic data at scale.
  • Stateful tests require careful data setup and teardown — data left behind causes test pollution.
  • For performance testing, data volume must represent realistic production scale, not a few records.
⚡ Expert Pro Tip

Build a dedicated test data service or library early in the project. Ad-hoc data creation scattered across test scripts is the number-one cause of flaky test suites.