Skip to content
SDETRole
SDETRole

Ticket prices at the age boundaries

beginner Boundary value analysis Challenge 1 of 10

A theme park sells tickets by age. Write tests that would catch a mistake in any implementation of the rules below.

Your tests are run against the correct implementation first, and then against ten buggy copies, each with one planted off-by-one or validation error. Your goal is to design tests that expose every bug.

Requirements

  • Ages are whole years. Valid ages are 0 to 120 inclusive. Anything else returns invalid.
  • Under 5 years: free (0).
  • 5 to 17: child ticket, 8.
  • 18 to 64: adult ticket, 15.
  • 65 and over: senior ticket, 10.
  • Every test needs an expected price that agrees with these rules.

Expected output

Tests that all match the specification and together expose all 10 planted bugs.

Function under test

ticketPrice(age) → price

  • age a number (whole years)

How your tests are checked

  • ○Every expected value agrees with the specification
  • ○Your tests expose all 10 planted bugs

The correct implementation is the oracle. A bug counts as caught when one of your valid tests gives a different result on the buggy copy than on the correct code.

testsMutation-tested in your browser
#agenumberwhole yearsexpected priceRemove
1
1 test

Ctrl/⌘ + Enter to check tests · your tests are saved in this browser

Results

Check your tests to see which planted bugs they catch.

Type to search across SDETRole.

Full-text search by Pagefind · runs in your browser Open search page →