From 5e3a97eaa4f59e410b2afb3947553400db27c358 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Tue, 13 Jun 2023 18:25:10 +0200 Subject: [PATCH 1/2] Add test coverage collection & reporting --- .config/dotnet-tools.json | 12 ++++++++++++ .editorconfig | 2 +- .gitignore | 1 + NCrontab.Tests/.runsettings | 7 +++++++ NCrontab.Tests/NCrontab.Tests.csproj | 4 ++++ appveyor.yml | 6 +++++- test.cmd | 20 ++++++++------------ test.sh | 17 ++++++++++------- 8 files changed, 48 insertions(+), 21 deletions(-) create mode 100644 .config/dotnet-tools.json create mode 100644 NCrontab.Tests/.runsettings diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..12262f5 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-reportgenerator-globaltool": { + "version": "5.1.22", + "commands": [ + "reportgenerator" + ] + } + } +} diff --git a/.editorconfig b/.editorconfig index 46779ac..906e425 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,7 +16,7 @@ indent_size = 2 [*.{sln}] indent_style = tab -[*.{json,yml}] +[*.{json,yml,xml,runsettings}] indent_size = 2 [*.{cs,tt}] diff --git a/.gitignore b/.gitignore index d296008..263ae55 100644 --- a/.gitignore +++ b/.gitignore @@ -370,3 +370,4 @@ __pycache__/ temp/ tmp/ +etc/coverage/ diff --git a/NCrontab.Tests/.runsettings b/NCrontab.Tests/.runsettings new file mode 100644 index 0000000..cc74b6b --- /dev/null +++ b/NCrontab.Tests/.runsettings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/NCrontab.Tests/NCrontab.Tests.csproj b/NCrontab.Tests/NCrontab.Tests.csproj index b2dc264..93a9924 100644 --- a/NCrontab.Tests/NCrontab.Tests.csproj +++ b/NCrontab.Tests/NCrontab.Tests.csproj @@ -10,6 +10,10 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/appveyor.yml b/appveyor.yml index 31349e3..d15f0be 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -35,7 +35,10 @@ build_script: $id = ([datetimeoffset]$env:APPVEYOR_REPO_COMMIT_TIMESTAMP).ToUniversalTime().ToString('yyyyMMdd''t''HHmm') if ($isWindows) { .\pack.cmd ci-$id } test_script: -- cmd: test.cmd +- cmd: | + call test.cmd + curl -OsSL https://uploader.codecov.io/latest/windows/codecov.exe + codecov - sh: ./test.sh for: - @@ -44,6 +47,7 @@ for: - image: Visual Studio 2022 artifacts: - path: dist\*.nupkg + - path: etc\coverage deploy: - provider: NuGet server: https://www.myget.org/F/raboof/api/v2/package diff --git a/test.cmd b/test.cmd index 73051c7..32d54ae 100644 --- a/test.cmd +++ b/test.cmd @@ -1,17 +1,13 @@ @echo off pushd "%~dp0" -call :main %* -popd -goto :EOF - -:main - call build ^ - && call :test Debug -p:CollectCoverage=true ^ - -p:CoverletOutputFormat=opencover ^ - -p:Exclude=[NUnit*]* ^ - && call :test Release -goto :EOF +dotnet tool restore ^ + && call build ^ + && call :test Debug ^ + && call :test Release ^ + && dotnet reportgenerator -reports:NCrontab.Tests\TestResults\*\coverage.cobertura.xml -targetdir:etc\coverage -reporttypes:TextSummary;Html ^ + && type etc\coverage\Summary.txt +popd && exit /b %ERRORLEVEL% :test -dotnet test --no-build -c %1 NCrontab.Tests +dotnet test --no-build -s NCrontab.Tests\.runsettings -c %* goto :EOF diff --git a/test.sh b/test.sh index 9339436..a3e04f9 100755 --- a/test.sh +++ b/test.sh @@ -1,12 +1,15 @@ #!/usr/bin/env bash set -e cd "$(dirname "$0")" +dotnet tool restore ./build.sh -for f in net7.0 net6.0; do { - dotnet test --no-build NCrontab.Tests -c Debug -f $f \ - -p:CollectCoverage=true \ - -p:CoverletOutputFormat=opencover \ - -p:Exclude=[NUnit*]* - dotnet test --no-build NCrontab.Tests -c Release -f $f -} +for f in net7.0 net6.0; do + for c in Debug Release; do + dotnet test --no-build -c $c -f $f \ + -s NCrontab.Tests/.runsettings + done done +dotnet reportgenerator "-reports:NCrontab.Tests/TestResults/*/coverage.cobertura.xml" \ + -targetdir:etc/coverage \ + -reporttypes:TextSummary;Html +cat etc/coverage/Summary.txt From 07079badf35fd29c01fec1edfe64d229ae938758 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Tue, 13 Jun 2023 18:37:51 +0200 Subject: [PATCH 2/2] Fix "test.sh" script --- test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.sh b/test.sh index a3e04f9..c5e74f1 100755 --- a/test.sh +++ b/test.sh @@ -9,7 +9,7 @@ for f in net7.0 net6.0; do -s NCrontab.Tests/.runsettings done done -dotnet reportgenerator "-reports:NCrontab.Tests/TestResults/*/coverage.cobertura.xml" \ +dotnet reportgenerator '-reports:NCrontab.Tests/TestResults/*/coverage.cobertura.xml' \ -targetdir:etc/coverage \ - -reporttypes:TextSummary;Html + '-reporttypes:TextSummary;Html' cat etc/coverage/Summary.txt