Improve documentation for different markdown documentation files. Goal is to simplify and make the language and content more clear.
3.6 KiB
3.6 KiB
Tests
There are different types of tests executed:
Common aspects for all tests:
💡 You can use path/module alias @/tests in import statements.
Unit tests
- Unit tests test each component in isolation.
- All unit tests goes under
./tests/unit. - They rely on stubs for isolation.
Unit tests structure
./src/- Includes source code that unit tests will test.
./tests/unit/- Includes test code.
- Tests follow same folder structure as
./src/.- E.g. if system under test lies in
./src/application/ApplicationFactory.tsthen its tests would be in test would be at./tests/unit/application/ApplicationFactory.spec.ts.
- E.g. if system under test lies in
shared/- Includes common functionality that's shared across unit tests.
Assertions/:- Common assertions that extend Chai Assertion Library.
- Asserting functions should start with
expectprefix.
TestCases/- Shared test cases.
- Functions that calls
it()from Mocha test framework should haveitprefix.- E.g.
itEachAbsentCollectionValue().
- E.g.
Stubs/- Includes stubs to be able to test components in isolation.
- Stubs have minimal and dummy behavior to be functional, they may also have spying or mocking functions.
Unit tests naming
- Each test suite first describe the system under test.
- E.g. tests for class
Application.tsare all insideApplication.spec.ts.
- E.g. tests for class
describeblocks tests for same function (if applicable).- E.g. test for
run()are insidedescribe('run', () => ..).
- E.g. test for
Act, arrange, assert
- Tests use act, arrange and assert (AAA) pattern when applicable.
- Arrange
- Sets up the test case.
- Starts with comment line
// arrange.
- Act
- Executes the actual test.
- Starts with comment line
// act.
- Assert
- Elicit some sort of expectation.
- 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.
- Vue CLI plugin
e2e-cypressconfigures E2E tests. - Test names and folders have logical structure based on tests executed.
- The structure is following:
cypress.json: Cypress configuration file../tests/e2e/: Base Cypress folder./specs/: Test files named with.spec.jsextension./plugins/index.js: Plugin file executed before loading project./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.