- 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
- HTTP Clients
- Tests should test database migrations, before merge to main branch
- Integration tests should run in PR gate before the merge
- 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 like Database, External API using in memory mocks.
- Run tests using Microsoft Test server integration testing framework.
- Use in-memory Entity framework for database
- Use Moq for other dependencies
- Developers should mock everything inside the controller
- Developers should cover authorization attributes and claims
- Developers should cover model validation and binding
- Write tests for each controller that tests business logic.
- should run in PR gate pipeline
Test that the application started and run
- Test database health check
- Test External system HttpClient (call health checks)
- Run a simple smoke test for the main flow in the microservice