Writing Good Unit Tests

  • AAA Arrange: Set up the necessary conditions and inputs for the test (e.g., mock objects, input data). Act: Execute the code or function being tested. Assert: Verify that the outcome matches the expected result.
  • Only test one thing
  • Focus on the essence of a test when arranging
  • keep your number of assertions ("expects") low

a boy reading books