Library › Cybersecurity AI › Software developers

Write the test cases that prove an access fix works

  • For Software developers
  • You practice Giving the right context
  • Time about 5 minutes

About this exercise

You fixed an invoice access bug and need tests that prove it. Write exactly 4 test names as it(...) lines in exactly 1 code block (no test bodies), covering the 4 cases in the acceptance criteria, using the team's naming style from the existing tests. Under 20 words outside the code.

Common mistakes when you ask AI for this

  • Generic tests. The AI writes its own cases, like 'handles errors', instead of your acceptance criteria. Try: Say: "One test per acceptance criterion, exactly 4."
  • Ignoring the naming style. The AI names tests 'should work for owner'. Try: Add: "Match our style: returns <status> when ..."
  • The textbook status code. The AI expects 403 for another customer's invoice. Try: Ask: "Another customer's invoice returns 404, not 403."
  • Full test files. The AI writes setup, mocks and bodies you didn't ask for. Try: Limit it: "Only 4 it(...) lines in 1 code block, no bodies."

What a strong prompt includes

  • Uses the acceptance criteria
  • Matches the naming style
  • Asks for names only
  • Asks for one code block
  • Limits the explanation

Practice this now ↑

Related exercises