Files
privacy.sexy/docs/tests.md
undergroundwires 60c80611ea add module alias '@tests/'
Alias would remove unnecessary repetitions and less relative paths make changes easier when moving around files. This commit cleans also up some relative paths ('../../../') by using the alias and orders imports. It updates both path alias in tsconfig and module alias in Vue CLI's bundler (vuejs/vue-cli#2398).
2021-04-15 18:34:40 +02:00

972 B

Tests

  • 💡 You can use path/module alias @/tests in import statements.

Unit tests

  • Unit tests are defined in ./tests
  • They follow same folder structure as ./src

Naming

  • Each test suite first describe the system under test
    • E.g. tests for class Application is categorized under Application
  • Tests for specific methods are categorized under method name (if applicable)
    • E.g. test for run() is categorized under run

Act, arrange, assert

  • Tests use act, arrange and assert (AAA) pattern when applicable
  • Arrange
    • Should set up the test case
    • Starts with comment line // arrange
  • Act
    • Should cover the main thing to be tested
    • Starts with comment line // act
  • Assert
    • Should elicit some sort of response
    • Starts with comment line // assert

Stubs

  • Stubs are defined in ./tests/stubs
  • They implement dummy behavior to be functional