|
| 1 | +To run test we need to generates packages to reference in on test project. |
| 2 | +Run from repo root |
| 3 | +``` |
| 4 | +C:\git\coverlet |
| 5 | +λ dotnet pack |
| 6 | +Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core |
| 7 | +Copyright (C) Microsoft Corporation. All rights reserved. |
| 8 | +
|
| 9 | + Restore completed in 73,36 ms for C:\git\coverlet\src\coverlet.core\coverlet.core.csproj. |
| 10 | + Restore completed in 73,41 ms for C:\git\coverlet\test\coverlet.testsubject\coverlet.testsubject.csproj. |
| 11 | + Restore completed in 73,33 ms for C:\git\coverlet\test\coverlet.tests.projectsample.excludedbyattribute\coverlet.tests.projectsample.excludedbyattribute.csproj. |
| 12 | + Restore completed in 73,34 ms for C:\git\coverlet\src\coverlet.collector\coverlet.collector.csproj. |
| 13 | + Restore completed in 73,35 ms for C:\git\coverlet\test\coverlet.tests.xunit.extensions\coverlet.tests.xunit.extensions.csproj. |
| 14 | + Restore completed in 75,92 ms for C:\git\coverlet\test\coverlet.integration.tests\coverlet.integration.tests.csproj. |
| 15 | + Restore completed in 73,41 ms for C:\git\coverlet\src\coverlet.console\coverlet.console.csproj. |
| 16 | + Restore completed in 73,36 ms for C:\git\coverlet\test\coverlet.tests.projectsample.empty\coverlet.tests.projectsample.empty.csproj. |
| 17 | + Restore completed in 73,47 ms for C:\git\coverlet\src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj. |
| 18 | + Restore completed in 73,37 ms for C:\git\coverlet\test\coverlet.core.tests.samples.netstandard\coverlet.core.tests.samples.netstandard.csproj. |
| 19 | + Restore completed in 76,37 ms for C:\git\coverlet\test\coverlet.collector.tests\coverlet.collector.tests.csproj. |
| 20 | + Restore completed in 77,05 ms for C:\git\coverlet\test\coverlet.integration.template\coverlet.integration.template.csproj. |
| 21 | + Restore completed in 77,2 ms for C:\git\coverlet\test\coverlet.core.performancetest\coverlet.core.performancetest.csproj. |
| 22 | + Restore completed in 87,7 ms for C:\git\coverlet\test\coverlet.core.tests\coverlet.core.tests.csproj. |
| 23 | + coverlet.core -> C:\git\coverlet\src\coverlet.core\bin\Debug\netstandard2.0\coverlet.core.dll |
| 24 | + coverlet.collector -> C:\git\coverlet\src\coverlet.collector\bin\Debug\netcoreapp2.0\coverlet.collector.dll |
| 25 | + coverlet.msbuild.tasks -> C:\git\coverlet\src\coverlet.msbuild.tasks\bin\Debug\netstandard2.0\coverlet.msbuild.tasks.dll |
| 26 | + coverlet.console -> C:\git\coverlet\src\coverlet.console\bin\Debug\netcoreapp2.2\coverlet.console.dll |
| 27 | + coverlet.console -> C:\git\coverlet\src\coverlet.console\bin\Debug\netcoreapp2.2\coverlet.console.dll |
| 28 | + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.1.3.0-preview.6.ga0e22ec622.nupkg'. |
| 29 | + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.console.1.7.2-preview.6.ga0e22ec622.nupkg'. |
| 30 | + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.console.1.7.2-preview.6.ga0e22ec622.snupkg'. |
| 31 | + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.1.3.0-preview.6.ga0e22ec622.snupkg'. |
| 32 | + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.msbuild.2.9.0-preview.6.ga0e22ec622.nupkg'. |
| 33 | + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.msbuild.2.9.0-preview.6.ga0e22ec622.snupkg'. |
| 34 | +``` |
| 35 | +Add msbuild package version generated to `"..\Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\XUnitTestProject1.csproj"` |
| 36 | +```xml |
| 37 | +<Project Sdk="Microsoft.NET.Sdk"> |
| 38 | + |
| 39 | + <PropertyGroup> |
| 40 | + <TargetFramework>netcoreapp3.1</TargetFramework> |
| 41 | + <IsPackable>false</IsPackable> |
| 42 | + </PropertyGroup> |
| 43 | + |
| 44 | + <ItemGroup> |
| 45 | + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" /> |
| 46 | + <PackageReference Include="xunit" Version="2.4.0" /> |
| 47 | + <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> |
| 48 | + <PackageReference Include="coverlet.collector" Version="1.2.0" /> |
| 49 | + <!-- version comes from coverlet.msbuild.2.9.0-preview.6.ga0e22ec622.nupkg --> |
| 50 | + <PackageReference Include="coverlet.msbuild" Version="2.9.0-preview.6.ga0e22ec622" > |
| 51 | + <PrivateAssets>all</PrivateAssets> |
| 52 | + <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
| 53 | + </PackageReference> |
| 54 | + </ItemGroup> |
| 55 | + |
| 56 | + <ItemGroup> |
| 57 | + <ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj" /> |
| 58 | + </ItemGroup> |
| 59 | + |
| 60 | +</Project> |
| 61 | + |
| 62 | +``` |
| 63 | +Go to test project folder and run |
| 64 | +``` |
| 65 | +C:\git\coverlet\Documentation\Examples\MSBuild\DeterministicBuild (detbuilddocs -> origin) |
| 66 | +λ dotnet test /p:CollectCoverage=true /p:DeterministicSourcePaths=true |
| 67 | +Test run for C:\git\coverlet\Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\bin\Debug\netcoreapp3.1\XUnitTestProject1.dll(.NETCoreApp,Version=v3.1) |
| 68 | +Microsoft (R) Test Execution Command Line Tool Version 16.5.0 |
| 69 | +Copyright (c) Microsoft Corporation. All rights reserved. |
| 70 | +
|
| 71 | +Starting test execution, please wait... |
| 72 | +
|
| 73 | +A total of 1 test files matched the specified pattern. |
| 74 | +
|
| 75 | +Test Run Successful. |
| 76 | +Total tests: 1 |
| 77 | + Passed: 1 |
| 78 | + Total time: 1,1471 Seconds |
| 79 | +
|
| 80 | +Calculating coverage result... |
| 81 | + Generating report 'C:\git\coverlet\Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\coverage.json' |
| 82 | +
|
| 83 | ++---------------+------+--------+--------+ |
| 84 | +| Module | Line | Branch | Method | |
| 85 | ++---------------+------+--------+--------+ |
| 86 | +| ClassLibrary1 | 100% | 100% | 100% | |
| 87 | ++---------------+------+--------+--------+ |
| 88 | +
|
| 89 | ++---------+------+--------+--------+ |
| 90 | +| | Line | Branch | Method | |
| 91 | ++---------+------+--------+--------+ |
| 92 | +| Total | 100% | 100% | 100% | |
| 93 | ++---------+------+--------+--------+ |
| 94 | +| Average | 100% | 100% | 100% | |
| 95 | ++---------+------+--------+--------+ |
| 96 | +``` |
| 97 | +You should see on output folder the coverlet source root mapping file generated. |
| 98 | +This is the confirmation that you're running coverage on deterministic build. |
| 99 | +``` |
| 100 | +Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\bin\Debug\netcoreapp3.1\CoverletSourceRootsMapping |
| 101 | +``` |
0 commit comments