Created
February 11, 2022 12:00
-
-
Save abodalevsky/3e256e8ce946e157e1e2b80547262037 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# script runs tests and calculate code coverage. | |
# coverlet and reportgenerator has to be installed | |
# https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-code-coverage?tabs=linux | |
RESULT_FOLDER="./PathToTestProject.UnitTests/TestResults" | |
rm -r -f $RESULT_FOLDER | |
dotnet test --collect:"XPlat Code Coverage" | |
result=$? | |
reportgenerator \ | |
-reports:`find $RESULT_FOLDER -name coverage.cobertura.xml` \ | |
-targetdir:$RESULT_FOLDER/reports \ | |
-reporttypes:Html | |
if [ $result = 0 ]; then | |
echo "All tests passed!" | |
else | |
echo "Some tests failed :(" | |
exit $result | |
fi | |
open $RESULT_FOLDER/reports/index.html | |
exit $result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment