General test pattern

Arrange

  • prepare and configure, set the state before running the test
  • set up db, connect to API

Act

  • performing action, calling a method
  • should elicit some sort of response

Assert

  • validate expected outcomes

Unit tests

Unit tests should generally be one(i.e. unit) functionality or thing tested. If there are too many assertions, it might be a sign that the functionality being tested is too complex and has to be refactored.

Calls to other modules, inside the module being tested, can be mocked so that for the expected hard-coded inputs, the output can be verified