-
Notifications
You must be signed in to change notification settings - Fork 44
/
coverage.sh
executable file
·50 lines (38 loc) · 1.46 KB
/
coverage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh -eu
# function to display commands
exe() { echo; echo "\$ $*" ; "$@" ; }
# Parameters
framework="${1-net7.0}"
config="${2-Debug}"
include="[Castle.Core.AsyncInterceptor]*"
exclude="\"[Castle.Core.AsyncInterceptor]*.NoCoverage.*,[*.Tests]*\""
# Cannot use a bash solution in alpine builds https://stackoverflow.com/a/246128
#rootDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
rootDir=$(pwd)
testResults="test/TestResults"
output="$rootDir/$testResults/output"
testProj1="$rootDir/test/Castle.Core.AsyncInterceptor.Tests/Castle.Core.AsyncInterceptor.Tests.csproj"
# Restore the packages
exe dotnet restore "$rootDir"
# Build the test projects
exe dotnet build --no-restore -f "$framework" -c "$config" "$testProj1"
# Execute the tests
exe dotnet test --no-restore --no-build -f "$framework" -c "$config" \
"$testProj1" \
--results-directory "$output/" \
--logger "trx;LogFileName=$(basename "$testProj1" .csproj).trx" \
--logger "html;LogFileName=$(basename "$testProj1" .csproj).html" \
-p:CollectCoverage=true \
-p:Include="$include" \
-p:Exclude="$exclude" \
-p:CoverletOutput="$output/" \
-p:CoverletOutputFormat="\"json,opencover,cobertura,lcov\""
exe dotnet tool restore
# Convert the MSTest trx files to junit xml
exe dotnet tool run trx2junit "$output"/*.trx
# Generate the reports
exe dotnet tool run reportgenerator \
"-verbosity:Info" \
"-reports:$output/coverage.$framework.opencover.xml" \
"-targetdir:$output/Report" \
"-reporttypes:Html"