forked from Travix-International/Hystrix.Dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coverage.sh
68 lines (52 loc) · 1.92 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
set -e
# Install OpenCover and ReportGenerator, and save the path to their executables.
nuget install -Verbosity quiet -OutputDirectory packages -Version 4.6.519 OpenCover
nuget install -Verbosity quiet -OutputDirectory packages -Version 2.4.5.0 ReportGenerator
OPENCOVER=$PWD/packages/OpenCover.4.6.519/tools/OpenCover.Console.exe
REPORTGENERATOR=$PWD/packages/ReportGenerator.2.4.5.0/tools/ReportGenerator.exe
CONFIG=Release
# Arguments to use for the build
DOTNET_BUILD_ARGS="-c $CONFIG"
# Arguments to use for the test
DOTNET_TEST_ARGS="$DOTNET_BUILD_ARGS"
echo CLI args: $DOTNET_BUILD_ARGS
echo Restoring
dotnet restore -v Warning
echo Building
dotnet build $DOTNET_BUILD_ARGS **/project.json
echo Testing
coverage=./coverage
rm -rf $coverage
mkdir $coverage
for testdir in test/*.UnitTests
do
# For example the test project directory is test/Hystrix.Dotnet.UnitTests
# We need to get the name of the project, to know what include in the OpenCover filter, so we have to extract the "Hystrix.Dotnet" part from the path string.
project=`echo $testdir | cut -d/ -f2 | sed -e 's/\(\.UnitTests\)*$//g'`
echo "Executing unit tests in $testdir"
#dotnet test -f netcoreapp1.0 $DOTNET_TEST_ARGS $testdir
dotnet test $DOTNET_TEST_ARGS $testdir
if [ "$project" = "Hystrix.Dotnet.AspNet" ]; then
seachdirs=$testdir/bin/$CONFIG/net451
else
seachdirs=$testdir/bin/$CONFIG/netcoreapp1.0
fi
echo "Calculating coverage with OpenCover for $project"
$OPENCOVER \
-target:"c:\Program Files\dotnet\dotnet.exe" \
-targetargs:"test $DOTNET_TEST_ARGS $testdir" \
-mergeoutput \
-hideskipped:File \
-output:$coverage/coverage.xml \
-oldStyle \
-filter:"+[$project*]* -[Hystrix.*Tests*]*" \
-excludebyfile:*Startup.cs \
-searchdirs:$searchdirs \
-register:user
done
echo "Generating HTML report"
$REPORTGENERATOR \
-reports:$coverage/coverage.xml \
-targetdir:$coverage \
-verbosity:Error