Understanding Unit Test

  1. What is a unit test?
    A unit test is a test that
  • Verifies a single unit of behaviour,
  • Does it quickly,
  • And in isolation from other tests.
  • Protection against regressions
  • Resistance to refactoring
  • Fast feedback
  • Maintainability
  1. Try to get as close to an actual business use case as possible and as far as possible from implementation details. Mimic user actions and assert user expectations. Never assert what the code should do internally. It is worth to mention that for JavaScript, the library `@testing-library` embraces and enforces this principle.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store