Paul's Python CoursePPC

Writing tests first

Not met yet

Writing the tests first means deciding exactly what a function should do, edges included, before writing it. Run the new tests and watch them fail: a test you've seen fail is one you know can fail. Then write the simplest code that makes them pass, and keep the tests for every change after that.

Try it

main.py

Output

Press Run and what your program prints shows up here.

Easy to get wrong

  • Thinks a test that fails before the code is written must be a broken test.
  • Thinks a passing test proves the code is right, even if the test has never been seen to fail.

Where it comes up