Coding with AI tools

Stage 5 · Lesson 4 of 6

Recognising tests that cannot fail

Tests first, so AI output is checked

AI-generated tests often look thorough and check nothing. Common forms: asserting that a (a fake stand-in for a real ) was called with the values the test itself passed in; snapshot tests that save output nobody reviews; tests with no at all; tests that only check a function returns something; and tests so heavily mocked that the real code never runs.

The quickest check is to break the code on purpose: change a > to >=, return early, or delete a line, then rerun. If nothing fails, the tests are decoration. tools such as Stryker, mutmut and PIT automate this by making many small changes and reporting which ones no test catches.

Common traptrusting a high number, which counts lines run, not whether any result was checked.

A question to check yourself, an AI practice session and 2 cheat sheet entries come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

Practise

  • Every exercise ships with tests: practise reading them first, then writing your own extras

Keep handy

Also worth your time

Mark this stage as not done?