Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Always remember to tests all positive and negative test scenarios and ensure that the proper results (error code, exception, message, etc.) are returned and provided in the later case.

Warning

Some error scenarios are extremely difficult to test using end-to-end or component/service tests, which makes testing all exception scenarios at the unit test level even more critical.

...

  • Assert that the expected value is returned
  • Assert that the object under test is in the expected state
  • Verify that all the mocked dependencies were called/not called as expected
  • Verify that all the mocked dependencies that were called were called with the right parameters
  • Have just enough assertions and verifications to prove that the test passes, but no less

Never assert or verify the same behavior in more than one test.

Mock Dependencies

Use Proper Clean Up Mechanisms

...