This repository have the pourpose of training my team in building effective tests and pass through some issues we find during the development, such as mapping errors, dependency injection, logical error, test implementation not following business and more.
Basically the application consists of consumming the MetaWeather API to get the weather by location and convert the results for the desired thermometric scale.
The tests are distributed in three layers of the bottom of the original test pyramid drawn by Martin Fowler. Follow the links for more information.
There are two branches in this repository for training, the main objective of both are to get to the maximum code coverage and mutant killed you can get.
The Broken
branch have some tests already implemented, with tests passing, breaking and missing. Use this to also improve your debugging skills.
The Missing
branch doesn't have any tests implemented, use your creativity and write them in your own code style and techniques.
Run command inside the api project folder:
$ dotnet run
Run command on the root folder or inside a test project folder:
$ dotnet test
If you don't have reportgenerator tool installed, go to the root of the project and run:
$ dotnet tool restore
On the root folder run the following commands:
$ dotnet test WeatherForecast.sln /p:CoverletOutputFormat=opencover /p:CoverletOutput=./TestResults/ /p:CollectCoverage=true
$ dotnet reportgenerator "-reports:./tests/WeatherForecast.UnitTest/TestResults/coverage.opencover.xml;./tests/WeatherForecast.IntegrationTest/TestResults/coverage.opencover.xml;./tests/WeatherForecast.FunctionalTest/TestResults/coverage.opencover.xml" "-targetdir:coveragereport" -reporttypes:Html
If you don't have dotnet-stryker installed, go to the root of the project and run:
$ dotnet tool restore
On WeatherForecast/tests/WeatherForecast.UnitTest run:
$ dotnet stryker --project-file=[projectfile]
- .NET Core 3.1 - Software Developmet Kit (SDK)
- xUnit.net - Unit Test Framework
- Fluent Assertions - Unit Test Assertions Extension Methods
- Moq - The most popular mocking library for .NET
- WireMock - A flexible library for stubbing and mocking web HTTP responses