Skip to content
SDETRole
SDETRole

Shipping fee: a decision table

advanced Decision tables Challenge 7 of 10

An online shop calculates the shipping fee for a parcel from its weight, the destination region and whether the customer chose express delivery. Write tests that expose every bug in nine buggy implementations.

Requirements

  • Weights above 0 and up to 30 kg are accepted. Anything else is rejected.
  • Base fee by region: domestic 5, eu 12, world 25.
  • Parcels heavier than 10 kg add a surcharge of 8 to the base fee.
  • Express delivery doubles the whole fee (base plus surcharge).
  • Express delivery is not available for world: the result is rejected.
  • Every test needs an expected fee that agrees with these rules.

Expected output

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

Function under test

shippingFee(weightKg, express, region) → fee

  • weightKg a number (kilograms, decimals allowed)
  • express true or false
  • region one of domestic, eu, world

How your tests are checked

  • ○Every expected value agrees with the specification
  • ○Your tests expose all 9 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
#weightKgnumberkilograms, decimals allowedexpressbooleanregionchoiceexpected feeRemove
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 →