Skip to content
SDETRole
SDETRole

Password rules: lengths and combinations

beginner Equivalence partitioning Challenge 2 of 10

A sign-up form validates passwords before sending them to the server. The checker receives the password’s length and two flags that were computed from it.

Write tests that would catch a mistake in any implementation of the rule. They are run against the correct implementation, and then against seven buggy copies.

Requirements

  • The length must be between 8 and 64 characters inclusive.
  • The password must contain at least one digit.
  • The password must contain at least one uppercase letter.
  • The result is valid only when all three conditions hold, otherwise invalid.

Expected output

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

Function under test

isValidPassword(length, hasDigit, hasUpper) → result

  • length a number (characters)
  • hasDigit true or false
  • hasUpper true or false (has an uppercase letter)

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
#lengthnumbercharactershasDigitbooleanhasUpperbooleanhas an uppercase letterexpected 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 →