- Unify test data for nonexistence of an object/string and collection. - Introduce more test through adding missing test data to existing tests. - Improve logic for checking absence of values to match tests. - Add missing tests for absent value validation. - Update documentation to include shared test functionality.
3.5 KiB
3.5 KiB
Tests
- There are two different types of tests executed:
- All tests
- 💡 You can use path/module alias
@/testsin import statements.
Unit tests
- Tests each component in isolation.
- Defined in
./tests/unit.
Unit tests structure
./src/- Includes code that will be tested tested.
./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.
- Test runner functions that uses
it()from Mocha test Mocha test framework should be prefixed withit.- E.g.
itEachAbsentCollectionValue().
- E.g.
stubs/- Includes stubs to be able to test classes in isolation.
- They implement dummy behavior to be functional with optionally spying or mocking functions.
Unit tests naming
- Each test suite first describe the system under test.
- E.g. tests for class
Applicationis categorized underApplication.
- E.g. tests for class
- Tests for specific methods are categorized under method name (if applicable).
- E.g. test for
run()is categorized underrun.
- E.g. test for
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-cypressfor 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.jsextension./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.