Files
privacy.sexy/docs/tests.md
undergroundwires 803ef2bb3e Move stubs from ./stubs to ./shared/Stubs
Gathers all shared test code in single place.
2022-01-25 08:37:03 +01:00

3.5 KiB

Tests

Unit tests

  • Tests each component in isolation.
  • Defined in ./tests/unit.

Unit tests structure

Unit tests 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.

Integration tests

  • Tests functionality of a component in combination with others (not isolated).
  • Ensure dependencies to third parties work as expected.
  • Defined in ./tests/integration.

E2E tests

  • Test the functionality and performance of a running application.
  • E2E tests are configured by vue plugin e2e-cypress for Vue CLI.
  • Names and folders are structured logically based on tests.
  • The structure is following:
    • cypress.json: Cypress configuration file.
    • ./tests/e2e/: Base Cypress folder.
      • /specs/: Test files, test are named with .spec.js extension.
      • /plugins/index.js: Plugin file executed before project is loaded.
      • /support/index.js: Support file, runs before every single spec file.
      • (Ignored) /videos: Asset folder for videos taken during tests.
      • (Ignored) /screenshots: Asset folder for Screenshots taken during tests.