lecture 5 of 150 completed

Tests that fight over the same data

Two tests using the same name will break each other. Give every test data that belongs only to it.

What you'll learn

  • Why two tests sharing data break each other
  • How to give every test data that belongs only to it
  • Why unique data beats careful cleanup

Two engineers can spend a whole afternoon on a failing build, reading the app code, checking the database, and blaming the server, when the real cause is two tests that both created a customer named "Test User".

This is one of the most confusing bugs you will meet, so let's walk through it slowly.

You have two tests. Both create a contact named "Dana Fox".

Run the first one alone: it passes. Run the second one alone: it passes. Run them together: the second one fails. It expected to find one Dana Fox and it found two.

full course

Keep reading with the full course

The Foundations track and the first lessons in each framework are free. This lesson needs full course access. A course plan includes all lessons for Playwright, Cypress and Selenium.

See course plans →