diff --git a/Documentation/Examples/MSBuild/DeterministicBuild/ClassLibrary1/Class1.cs b/Documentation/Examples/MSBuild/DeterministicBuild/ClassLibrary1/Class1.cs new file mode 100644 index 0000000..289865e --- /dev/null +++ b/Documentation/Examples/MSBuild/DeterministicBuild/ClassLibrary1/Class1.cs @@ -0,0 +1,12 @@ +using System; + +namespace ClassLibrary1 +{ + public class Class1 + { + public int Method() + { + return 42; + } + } +} diff --git a/Documentation/Examples/MSBuild/DeterministicBuild/ClassLibrary1/ClassLibrary1.csproj b/Documentation/Examples/MSBuild/DeterministicBuild/ClassLibrary1/ClassLibrary1.csproj new file mode 100644 index 0000000..9f5c4f4 --- /dev/null +++ b/Documentation/Examples/MSBuild/DeterministicBuild/ClassLibrary1/ClassLibrary1.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/Documentation/Examples/MSBuild/DeterministicBuild/DeterministicBuild.sln b/Documentation/Examples/MSBuild/DeterministicBuild/DeterministicBuild.sln new file mode 100644 index 0000000..e5ea12e --- /dev/null +++ b/Documentation/Examples/MSBuild/DeterministicBuild/DeterministicBuild.sln @@ -0,0 +1,59 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30014.187 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XUnitTestProject1", "XUnitTestProject1\XUnitTestProject1.csproj", "{BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8AE3B75E-33BA-4E07-AD78-2DBCC3392262}" + ProjectSection(SolutionItems) = preProject + DeterministicBuild.targets = DeterministicBuild.targets + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets + HowTo.md = HowTo.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Debug|x64.ActiveCfg = Debug|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Debug|x64.Build.0 = Debug|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Debug|x86.ActiveCfg = Debug|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Debug|x86.Build.0 = Debug|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Release|Any CPU.Build.0 = Release|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Release|x64.ActiveCfg = Release|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Release|x64.Build.0 = Release|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Release|x86.ActiveCfg = Release|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Release|x86.Build.0 = Release|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Debug|x64.ActiveCfg = Debug|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Debug|x64.Build.0 = Debug|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Debug|x86.ActiveCfg = Debug|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Debug|x86.Build.0 = Debug|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Release|Any CPU.Build.0 = Release|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Release|x64.ActiveCfg = Release|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Release|x64.Build.0 = Release|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Release|x86.ActiveCfg = Release|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {89E650B4-E15F-46F0-B8F4-CE372B2092AB} + EndGlobalSection +EndGlobal diff --git a/Documentation/Examples/MSBuild/DeterministicBuild/DeterministicBuild.targets b/Documentation/Examples/MSBuild/DeterministicBuild/DeterministicBuild.targets new file mode 100644 index 0000000..7805293 --- /dev/null +++ b/Documentation/Examples/MSBuild/DeterministicBuild/DeterministicBuild.targets @@ -0,0 +1,23 @@ + + + + + $([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)')) + + + + + + + + + + + <_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/> + + + diff --git a/Documentation/Examples/MSBuild/DeterministicBuild/Directory.Build.props b/Documentation/Examples/MSBuild/DeterministicBuild/Directory.Build.props new file mode 100644 index 0000000..5c27e11 --- /dev/null +++ b/Documentation/Examples/MSBuild/DeterministicBuild/Directory.Build.props @@ -0,0 +1,13 @@ + + + + + https://api.nuget.org/v3/index.json; + ..\..\..\..\..\bin\$(Configuration)\Packages + + + + + + + diff --git a/Documentation/Examples/MSBuild/DeterministicBuild/Directory.Build.targets b/Documentation/Examples/MSBuild/DeterministicBuild/Directory.Build.targets new file mode 100644 index 0000000..95978e1 --- /dev/null +++ b/Documentation/Examples/MSBuild/DeterministicBuild/Directory.Build.targets @@ -0,0 +1,4 @@ + + + + diff --git a/Documentation/Examples/MSBuild/DeterministicBuild/HowTo.md b/Documentation/Examples/MSBuild/DeterministicBuild/HowTo.md new file mode 100644 index 0000000..44b9f2b --- /dev/null +++ b/Documentation/Examples/MSBuild/DeterministicBuild/HowTo.md @@ -0,0 +1,101 @@ +To run test we need to generates packages to reference in on test project. +Run from repo root +``` +C:\git\coverlet +λ dotnet pack +Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core +Copyright (C) Microsoft Corporation. All rights reserved. + + Restore completed in 73,36 ms for C:\git\coverlet\src\coverlet.core\coverlet.core.csproj. + Restore completed in 73,41 ms for C:\git\coverlet\test\coverlet.testsubject\coverlet.testsubject.csproj. + Restore completed in 73,33 ms for C:\git\coverlet\test\coverlet.tests.projectsample.excludedbyattribute\coverlet.tests.projectsample.excludedbyattribute.csproj. + Restore completed in 73,34 ms for C:\git\coverlet\src\coverlet.collector\coverlet.collector.csproj. + Restore completed in 73,35 ms for C:\git\coverlet\test\coverlet.tests.xunit.extensions\coverlet.tests.xunit.extensions.csproj. + Restore completed in 75,92 ms for C:\git\coverlet\test\coverlet.integration.tests\coverlet.integration.tests.csproj. + Restore completed in 73,41 ms for C:\git\coverlet\src\coverlet.console\coverlet.console.csproj. + Restore completed in 73,36 ms for C:\git\coverlet\test\coverlet.tests.projectsample.empty\coverlet.tests.projectsample.empty.csproj. + Restore completed in 73,47 ms for C:\git\coverlet\src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj. + Restore completed in 73,37 ms for C:\git\coverlet\test\coverlet.core.tests.samples.netstandard\coverlet.core.tests.samples.netstandard.csproj. + Restore completed in 76,37 ms for C:\git\coverlet\test\coverlet.collector.tests\coverlet.collector.tests.csproj. + Restore completed in 77,05 ms for C:\git\coverlet\test\coverlet.integration.template\coverlet.integration.template.csproj. + Restore completed in 77,2 ms for C:\git\coverlet\test\coverlet.core.performancetest\coverlet.core.performancetest.csproj. + Restore completed in 87,7 ms for C:\git\coverlet\test\coverlet.core.tests\coverlet.core.tests.csproj. + coverlet.core -> C:\git\coverlet\src\coverlet.core\bin\Debug\netstandard2.0\coverlet.core.dll + coverlet.collector -> C:\git\coverlet\src\coverlet.collector\bin\Debug\netcoreapp2.0\coverlet.collector.dll + coverlet.msbuild.tasks -> C:\git\coverlet\src\coverlet.msbuild.tasks\bin\Debug\netstandard2.0\coverlet.msbuild.tasks.dll + coverlet.console -> C:\git\coverlet\src\coverlet.console\bin\Debug\netcoreapp2.2\coverlet.console.dll + coverlet.console -> C:\git\coverlet\src\coverlet.console\bin\Debug\netcoreapp2.2\coverlet.console.dll + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.1.3.0-preview.6.ga0e22ec622.nupkg'. + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.console.1.7.2-preview.6.ga0e22ec622.nupkg'. + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.console.1.7.2-preview.6.ga0e22ec622.snupkg'. + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.1.3.0-preview.6.ga0e22ec622.snupkg'. + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.msbuild.2.9.0-preview.6.ga0e22ec622.nupkg'. + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.msbuild.2.9.0-preview.6.ga0e22ec622.snupkg'. +``` +Add msbuild package version generated to `"..\Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\XUnitTestProject1.csproj"` +```xml + + + + netcoreapp3.1 + false + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + +``` +Go to test project folder and run +``` +C:\git\coverlet\Documentation\Examples\MSBuild\DeterministicBuild (detbuilddocs -> origin) +λ dotnet test /p:CollectCoverage=true /p:DeterministicSourcePaths=true +Test run for C:\git\coverlet\Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\bin\Debug\netcoreapp3.1\XUnitTestProject1.dll(.NETCoreApp,Version=v3.1) +Microsoft (R) Test Execution Command Line Tool Version 16.5.0 +Copyright (c) Microsoft Corporation. All rights reserved. + +Starting test execution, please wait... + +A total of 1 test files matched the specified pattern. + +Test Run Successful. +Total tests: 1 + Passed: 1 + Total time: 1,1471 Seconds + +Calculating coverage result... + Generating report 'C:\git\coverlet\Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\coverage.json' + ++---------------+------+--------+--------+ +| Module | Line | Branch | Method | ++---------------+------+--------+--------+ +| ClassLibrary1 | 100% | 100% | 100% | ++---------------+------+--------+--------+ + ++---------+------+--------+--------+ +| | Line | Branch | Method | ++---------+------+--------+--------+ +| Total | 100% | 100% | 100% | ++---------+------+--------+--------+ +| Average | 100% | 100% | 100% | ++---------+------+--------+--------+ +``` +You should see on output folder the coverlet source root mapping file generated. +This is the confirmation that you're running coverage on deterministic build. +``` +Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\bin\Debug\netcoreapp3.1\CoverletSourceRootsMapping +``` \ No newline at end of file diff --git a/Documentation/Examples/MSBuild/DeterministicBuild/XUnitTestProject1/UnitTest1.cs b/Documentation/Examples/MSBuild/DeterministicBuild/XUnitTestProject1/UnitTest1.cs new file mode 100644 index 0000000..5eeb5df --- /dev/null +++ b/Documentation/Examples/MSBuild/DeterministicBuild/XUnitTestProject1/UnitTest1.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace XUnitTestProject1 +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + new ClassLibrary1.Class1().Method(); + } + } +} diff --git a/Documentation/Examples/MSBuild/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj b/Documentation/Examples/MSBuild/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj new file mode 100644 index 0000000..de3e88f --- /dev/null +++ b/Documentation/Examples/MSBuild/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj @@ -0,0 +1,23 @@ + + + + netcoreapp3.1 + false + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/Documentation/Examples/VSTest/DeterministicBuild/ClassLibrary1/Class1.cs b/Documentation/Examples/VSTest/DeterministicBuild/ClassLibrary1/Class1.cs new file mode 100644 index 0000000..289865e --- /dev/null +++ b/Documentation/Examples/VSTest/DeterministicBuild/ClassLibrary1/Class1.cs @@ -0,0 +1,12 @@ +using System; + +namespace ClassLibrary1 +{ + public class Class1 + { + public int Method() + { + return 42; + } + } +} diff --git a/Documentation/Examples/VSTest/DeterministicBuild/ClassLibrary1/ClassLibrary1.csproj b/Documentation/Examples/VSTest/DeterministicBuild/ClassLibrary1/ClassLibrary1.csproj new file mode 100644 index 0000000..9f5c4f4 --- /dev/null +++ b/Documentation/Examples/VSTest/DeterministicBuild/ClassLibrary1/ClassLibrary1.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/Documentation/Examples/VSTest/DeterministicBuild/DeterministicBuild.sln b/Documentation/Examples/VSTest/DeterministicBuild/DeterministicBuild.sln new file mode 100644 index 0000000..e5ea12e --- /dev/null +++ b/Documentation/Examples/VSTest/DeterministicBuild/DeterministicBuild.sln @@ -0,0 +1,59 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30014.187 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XUnitTestProject1", "XUnitTestProject1\XUnitTestProject1.csproj", "{BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8AE3B75E-33BA-4E07-AD78-2DBCC3392262}" + ProjectSection(SolutionItems) = preProject + DeterministicBuild.targets = DeterministicBuild.targets + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets + HowTo.md = HowTo.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Debug|x64.ActiveCfg = Debug|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Debug|x64.Build.0 = Debug|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Debug|x86.ActiveCfg = Debug|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Debug|x86.Build.0 = Debug|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Release|Any CPU.Build.0 = Release|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Release|x64.ActiveCfg = Release|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Release|x64.Build.0 = Release|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Release|x86.ActiveCfg = Release|Any CPU + {BFF46C49-E8A2-4BA9-9A8D-C56C933E3973}.Release|x86.Build.0 = Release|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Debug|x64.ActiveCfg = Debug|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Debug|x64.Build.0 = Debug|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Debug|x86.ActiveCfg = Debug|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Debug|x86.Build.0 = Debug|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Release|Any CPU.Build.0 = Release|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Release|x64.ActiveCfg = Release|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Release|x64.Build.0 = Release|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Release|x86.ActiveCfg = Release|Any CPU + {47C1D631-2ACB-47CF-BE3A-F8FA42715D7B}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {89E650B4-E15F-46F0-B8F4-CE372B2092AB} + EndGlobalSection +EndGlobal diff --git a/Documentation/Examples/VSTest/DeterministicBuild/DeterministicBuild.targets b/Documentation/Examples/VSTest/DeterministicBuild/DeterministicBuild.targets new file mode 100644 index 0000000..7805293 --- /dev/null +++ b/Documentation/Examples/VSTest/DeterministicBuild/DeterministicBuild.targets @@ -0,0 +1,23 @@ + + + + + $([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)')) + + + + + + + + + + + <_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/> + + + diff --git a/Documentation/Examples/VSTest/DeterministicBuild/Directory.Build.props b/Documentation/Examples/VSTest/DeterministicBuild/Directory.Build.props new file mode 100644 index 0000000..5c27e11 --- /dev/null +++ b/Documentation/Examples/VSTest/DeterministicBuild/Directory.Build.props @@ -0,0 +1,13 @@ + + + + + https://api.nuget.org/v3/index.json; + ..\..\..\..\..\bin\$(Configuration)\Packages + + + + + + + diff --git a/Documentation/Examples/VSTest/DeterministicBuild/Directory.Build.targets b/Documentation/Examples/VSTest/DeterministicBuild/Directory.Build.targets new file mode 100644 index 0000000..95978e1 --- /dev/null +++ b/Documentation/Examples/VSTest/DeterministicBuild/Directory.Build.targets @@ -0,0 +1,4 @@ + + + + diff --git a/Documentation/Examples/VSTest/DeterministicBuild/HowTo.md b/Documentation/Examples/VSTest/DeterministicBuild/HowTo.md new file mode 100644 index 0000000..b1002a6 --- /dev/null +++ b/Documentation/Examples/VSTest/DeterministicBuild/HowTo.md @@ -0,0 +1,82 @@ +To run test we need to generates packages to reference in on test project. +Run from repo root +``` +C:\git\coverlet +λ dotnet pack +Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core +Copyright (C) Microsoft Corporation. All rights reserved. + + Restore completed in 73,36 ms for C:\git\coverlet\src\coverlet.core\coverlet.core.csproj. + Restore completed in 73,41 ms for C:\git\coverlet\test\coverlet.testsubject\coverlet.testsubject.csproj. + Restore completed in 73,33 ms for C:\git\coverlet\test\coverlet.tests.projectsample.excludedbyattribute\coverlet.tests.projectsample.excludedbyattribute.csproj. + Restore completed in 73,34 ms for C:\git\coverlet\src\coverlet.collector\coverlet.collector.csproj. + Restore completed in 73,35 ms for C:\git\coverlet\test\coverlet.tests.xunit.extensions\coverlet.tests.xunit.extensions.csproj. + Restore completed in 75,92 ms for C:\git\coverlet\test\coverlet.integration.tests\coverlet.integration.tests.csproj. + Restore completed in 73,41 ms for C:\git\coverlet\src\coverlet.console\coverlet.console.csproj. + Restore completed in 73,36 ms for C:\git\coverlet\test\coverlet.tests.projectsample.empty\coverlet.tests.projectsample.empty.csproj. + Restore completed in 73,47 ms for C:\git\coverlet\src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj. + Restore completed in 73,37 ms for C:\git\coverlet\test\coverlet.core.tests.samples.netstandard\coverlet.core.tests.samples.netstandard.csproj. + Restore completed in 76,37 ms for C:\git\coverlet\test\coverlet.collector.tests\coverlet.collector.tests.csproj. + Restore completed in 77,05 ms for C:\git\coverlet\test\coverlet.integration.template\coverlet.integration.template.csproj. + Restore completed in 77,2 ms for C:\git\coverlet\test\coverlet.core.performancetest\coverlet.core.performancetest.csproj. + Restore completed in 87,7 ms for C:\git\coverlet\test\coverlet.core.tests\coverlet.core.tests.csproj. + coverlet.core -> C:\git\coverlet\src\coverlet.core\bin\Debug\netstandard2.0\coverlet.core.dll + coverlet.collector -> C:\git\coverlet\src\coverlet.collector\bin\Debug\netcoreapp2.0\coverlet.collector.dll + coverlet.msbuild.tasks -> C:\git\coverlet\src\coverlet.msbuild.tasks\bin\Debug\netstandard2.0\coverlet.msbuild.tasks.dll + coverlet.console -> C:\git\coverlet\src\coverlet.console\bin\Debug\netcoreapp2.2\coverlet.console.dll + coverlet.console -> C:\git\coverlet\src\coverlet.console\bin\Debug\netcoreapp2.2\coverlet.console.dll + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.1.3.0-preview.6.ga0e22ec622.nupkg'. + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.console.1.7.2-preview.6.ga0e22ec622.nupkg'. + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.console.1.7.2-preview.6.ga0e22ec622.snupkg'. + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.1.3.0-preview.6.ga0e22ec622.snupkg'. + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.msbuild.2.9.0-preview.6.ga0e22ec622.nupkg'. + Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.msbuild.2.9.0-preview.6.ga0e22ec622.snupkg'. +``` +Add collectors package version generated to `"..\Documentation\Examples\VSTest\DeterministicBuild\XUnitTestProject1\XUnitTestProject1.csproj"` +```xml + + + + netcoreapp3.1 + false + + + + + + + + + + + + + + + + +``` +Go to test project folder and run +``` +C:\git\coverlet\Documentation\Examples\VSTest\DeterministicBuild (detbuilddocs -> origin) +λ dotnet test --collect:"XPlat Code Coverage" /p:DeterministicSourcePaths=true +Test run for C:\git\coverlet\Documentation\Examples\VSTest\DeterministicBuild\XUnitTestProject1\bin\Debug\netcoreapp3.1\XUnitTestProject1.dll(.NETCoreApp,Version=v3.1) +Microsoft (R) Test Execution Command Line Tool Version 16.5.0 +Copyright (c) Microsoft Corporation. All rights reserved. + +Starting test execution, please wait... + +A total of 1 test files matched the specified pattern. + +Attachments: + C:\git\coverlet\Documentation\Examples\VSTest\DeterministicBuild\XUnitTestProject1\TestResults\7305d38e-0134-4fda-a99c-3672b410f472\coverage.cobertura.xml +Test Run Successful. +Total tests: 1 + Passed: 1 + Total time: 1,3472 Seconds +``` +You should see on output folder the coverlet source root mapping file generated. +This is the confirmation that you're running coverage on deterministic build. +``` +Documentation\Examples\VSTest\DeterministicBuild\XUnitTestProject1\bin\Debug\netcoreapp3.1\CoverletSourceRootsMapping +``` \ No newline at end of file diff --git a/Documentation/Examples/VSTest/DeterministicBuild/XUnitTestProject1/UnitTest1.cs b/Documentation/Examples/VSTest/DeterministicBuild/XUnitTestProject1/UnitTest1.cs new file mode 100644 index 0000000..5eeb5df --- /dev/null +++ b/Documentation/Examples/VSTest/DeterministicBuild/XUnitTestProject1/UnitTest1.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace XUnitTestProject1 +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + new ClassLibrary1.Class1().Method(); + } + } +} diff --git a/Documentation/Examples/VSTest/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj b/Documentation/Examples/VSTest/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj new file mode 100644 index 0000000..ea3c582 --- /dev/null +++ b/Documentation/Examples/VSTest/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj @@ -0,0 +1,19 @@ + + + + netcoreapp3.1 + false + + + + + + + + + + + + + +