Skip to content
SDETRole
SDETRole

The triangle classifier

intermediate Test case design Challenge 5 of 10

A geometry helper classifies a triangle from the lengths of its three sides. Write tests that expose every bug in seven buggy implementations.

Requirements

  • If any side is zero or negative, the result is invalid.
  • If the sides cannot form a triangle (the sum of any two sides is not greater than the third), the result is not a triangle.
  • Otherwise: three equal sides are equilateral, exactly two equal sides are isosceles, no equal sides are scalene.
  • Every test needs an expected result that agrees with these rules.

Expected output

Tests that match the specification and expose all 7 planted bugs.

Function under test

classifyTriangle(a, b, c) → result

  • a a number
  • b a number
  • c a number

How your tests are checked

  • ○Every expected value agrees with the specification
  • ○Your tests expose all 7 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
#anumberbnumbercnumberexpected resultRemove
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 →