It’s not just about Write tests, but writing tests that you can trust.

Test the behaviour, not the implementation.

Only test the things that could possibly break. Kent Beck

Thumb rules:

  • A flaky test is worth less than no test.
  • It’s hard to test the behaviour instead of the implementation; try to test a group of functions instead of testing each function individually.
  • If you test what changes state, you don’t need to test what returns state, because you will be using those functions to validate that the state changed anyway.
  • I like to write too many tests, then remove them later to reduce test brittleness