I am using the following bat file to generate code coverage report using OpenCover.
rmdir /s /q artifacts
mkdir artifacts
set sharedProject[0]="src\BuildingBlocks\Shared\tests\Common.API.UnitTests"
for /F "tokens=2 delims==" %%s in ('set sharedProject[') do (
cd %%s
"..\..\..\..\..\tools\OpenCover\OpenCover.Console.exe" ^
-target:"c:\Program Files\dotnet\dotnet.exe" ^
-targetargs:" xunit --fx-version 2.1.2 --no-build -xml ../../../../../artifacts/tests/%%s.xml" ^
-mergeoutput ^
-hideskipped:File ^
-output:"..\..\..\..\..\artifacts\opencover.xml" ^
-oldStyle ^
-skipautoprops ^
-filter:"+[companyName.*]*" ^
-register:regsvr32
cd ..\..\..\..\..
)
I run everything fine through visual studio, but when I try to run this script, some assemblies (Nuget package) cannot be found or loaded. So, some tests fail and others pass.
Before running the script I tried to delete the bin folders and execute:
dotnet restore
dotnet build
I've changed the above script to the follow one and everything worked fine:
rmdir /s /q artifacts
mkdir artifacts
set sharedProject[0]="src\BuildingBlocks\Shared\tests\Common.API.UnitTests"
for /F "tokens=2 delims==" %%s in ('set sharedProject[') do (
cd %%s
"..\..\..\..\..\tools\OpenCover\OpenCover.Console.exe" ^
-target:"c:\Program Files\dotnet\dotnet.exe" ^
-targetargs:"test --no-build" ^
-mergeoutput ^
-hideskipped:File ^
-output:"..\..\..\..\..\artifacts\opencover.xml" ^
-oldStyle ^
-skipautoprops ^
-filter:"+[companyName.*]*" ^
-register:regsvr32
cd ..\..\..\..\..
)
However I can't save the test results using "dotnet test". Any ideas why some Nuget packages fail to load when using dotnet xunit?
I am using .NET Core 2.1 and the two Nuget Packages which I am having problem are: Microsot.Extensions.Configuration.Abstraction and Newtonsoft.Json