lecture 5 of 190 completed

Where the expected value comes from

Two screens that agree prove they share a calculation, not that it is right. Take the expected value from the inputs, not from the app.

What you'll learn

  • Why comparing one screen with another can pass when both are wrong
  • Where a trustworthy expected value comes from: the inputs, your own test data, or a worked example
  • Why the test's own calculation must stay much simpler than the app's

Harbour Print sells posters and flyers. An invoice lists each line with a unit price and a quantity. At the bottom it shows a total. A Pay invoice button opens a payment page that shows the amount due.

Your test opens the invoice and reads the total. Then it opens the payment page and checks that the amount due is the same. The test passes. It also passes when the total is wrong.

Here is how. Both screens get their number from the same function in the app. One day that function forgets the last line of the invoice. The invoice shows the wrong total, the payment page shows the same wrong total, and they agree. Your test compares them, so it passes. A customer pays less than they owe, and the shop finds out at the end of the month.

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 →