- Unit, Integration, Component, and Contract tests should be written by developers
- E2E tests should be written by Automation test engineers
- Developers should support Automation test engineers with tools for mocking and test data setup
- Developers should write unit tests for every newly added class
- Developers should write tests for existing classes, covering only newly added logic
- All interactions and collaborations between an object and its dependencies, should be replaced by test doubles (Solitary unit testing)
- Using code coverage extension FineCodeCoverage in Visual studio to validate coverage
- Unit tests should be part of the story
- If unit tests are not possible to write because of business pressure, a tech dept task should be created with a list of classes that don't cover with tests, PM should notified that tests should be written after releases as first priority
Cover everything that is possible with unit tests
- Classes with business logic
- Controllers
- Attributes
- Model Validators
- Filters
- etc ..
- Run manually by developers locally using Fine code coverage extension
- Run in PR before the merge, all tests should pass
- Measure code coverage using Visual studio test task
- Setup baseline for test coverage and revision condition each month
- Developers should write integration tests for every newly added repository class
- Developers should write integration tests for existing classes, covering only newly added logic
- Setup test data using SQL or EF queries
- Each test should set and clean test data
- Tests should support running in parallel
- Repositories
- External clients (optional)
- Integration tests should run in PR gate before the merge
- It should test migrations when merging to develop environment
- Make a backup of the latest copy of the database and remove redundant data
- Run database in docker container using tmpfs (in memory storage)
- Before starting an integration test run docker inside test using docker client and stop it after
In a microservices architecture, a component can be a single microservice itself.
- Developers should mock all external dependencies (Database, External API)
- Cover Responses of the component from API perspective
Note: In process controllers component tests
- Developers should mock everything inside the controller
- Developers should cover authorization attributes and claims
- Developers should cover model validation and binding
- Developers should cover everything that is impossible to cover using Unit Tests
- Developers should mock all external dependencies except databases
- Developers should cover one successful test case from API to database for each new endpoint
- Should run in PR gate before the merge
- Developers should cover internal microservices http clients pact
- Developers should cover events contracts, pact messaging can be used
- should run in an independent pipeline when contract tests are updated, all microservices should check to verify compatibility
Test that the application started and run
- Test database health check
- Test External system HttpClient (call health checks) Test short smoke
- Test a simple short smoke
