Unit Testing and Code Coverage

To maintain high levels of code quality and ensure various future code changes do not affect existing code, it is important to implement unit tests. Microsoft Unit Testing framework should be used.

The standard “Arrange, Act, Assert” pattern should be used when writing unit tests.

Each unit test should test one thing and only one thing.

Separation of concern and single responsibility principals should be followed when writing unit tests and refactoring associated code.

The goal is to achieve as much code coverage from unit tests as possible. Overall, each solution should strive for code coverage at 85% or higher.

“Fakes” and mocking frameworks should not be used in unit testing. Refactor the code with abstractions and dependency injection to avoid using fakes and mocking frameworks.

Build pipelines should be configured to automatically run unit tests and collect/publish code coverage results after a success build.

For more information about unit testing, visit https://docs.microsoft.com/en-us/visualstudio/test/unit-test-your-code

PREVIOUS: Data Access and ORM
Solution Architecture Guidance
NEXT: File Storage