Skip to content

Instantly share code, notes, and snippets.

@abodalevsky
Created February 11, 2022 12:00
Show Gist options
  • Save abodalevsky/3e256e8ce946e157e1e2b80547262037 to your computer and use it in GitHub Desktop.
Save abodalevsky/3e256e8ce946e157e1e2b80547262037 to your computer and use it in GitHub Desktop.
#!/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