Various notes on testing.

Testing with FIRST principles

Link: here

The FIRST principles of testing stand for:

  • FAST - tests should run fast, slow tests are a deterrent to developers running them.
  • Isolated/Independent - tests should have no external dependencies
  • Repeatable - you should be able to run a test over and over again, no state outside the test is affected
  • Self-validating - the outcome of the test is asserted inside the test
  • Thorough - assertions are appropriate and complete

Other Notes On Testing

  • It’s okay and sometimes better to have repetition in tests. Tests don’tneed to be DRY.

BASIC testing principles

Similar to FIRST. Link.

  • Black box
  • Annotative
  • Single door
  • Independent
  • Copy

In My Words

Unit tests should have these things:

  • Mock any external dependcies
  • Be infinitely repeatable
  • Test one thing

UNIT tests

A unit test shouldn’t:

🚫 Call a DB 🚫 Run a browser 🚫 Make an HTTP call 🚫 Rely on stuff on other machines

A unit test should pass without a network connection.

There’s nothing wrong with doing such things in a test. But if a test does these things, it’s not a unit test.

end of storey Last modified: