Skip to content

Commit 868e663

Browse files
Add /p:MergeWith example on guide (#540)
add `/p:MergeWith` example.
1 parent 1bb08bb commit 868e663

File tree

16 files changed

+244
-0
lines changed

16 files changed

+244
-0
lines changed

Documentation/Examples.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Examples
2+
3+
## MSBuild Integration
4+
* Use `/p:MergeWith` feature `Documentation/Examples/MSBuild/MergeWith/MergeWith.sln`
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace ClassLibrary1
4+
{
5+
public class Class1
6+
{
7+
public int Method()
8+
{
9+
return 42;
10+
}
11+
}
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace ClassLibrary2
4+
{
5+
public class Class2
6+
{
7+
public int Method()
8+
{
9+
return 42;
10+
}
11+
}
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace ClassLibrary3
4+
{
5+
public class Class3
6+
{
7+
public int Method()
8+
{
9+
return 42;
10+
}
11+
}
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
</Project>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**Run from solution root sln**
2+
3+
To merge report togheter you need to run separate test and merge in one `json` format file.
4+
Last command will join and create final needed format file.
5+
6+
```
7+
dotnet test XUnitTestProject1\XUnitTestProject1.csproj /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/
8+
dotnet test XUnitTestProject2\XUnitTestProject2.csproj /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json"
9+
dotnet test XUnitTestProject3\XUnitTestProject3.csproj /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json" /p:CoverletOutputFormat="opencover"
10+
```
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29230.61
5+
MinimumVisualStudioVersion = 15.0.26124.0
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{4B6E5DCB-C16F-4880-AA97-BC5D01959E49}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTestProject1", "XUnitTestProject1\XUnitTestProject1.csproj", "{39597E4B-23B4-4A6A-A71B-FFBE131A94D6}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary2", "ClassLibrary2\ClassLibrary2.csproj", "{973ECB19-5301-4191-9D93-3BEC9D2FCCF6}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTestProject2", "XUnitTestProject2\XUnitTestProject2.csproj", "{6ED65535-CCC9-438E-80D4-1598FB572512}"
13+
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5F5E20F4-E34C-48BB-906D-65CF1B55A6AA}"
15+
ProjectSection(SolutionItems) = preProject
16+
MergeWith.md = MergeWith.md
17+
EndProjectSection
18+
EndProject
19+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary3", "ClassLibrary3\ClassLibrary3.csproj", "{2443A7B5-99D5-40EA-9501-CCE80FC8951A}"
20+
EndProject
21+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTestProject3", "XUnitTestProject3\XUnitTestProject3.csproj", "{FE26E5E2-B692-4FF2-86BE-E3E3DC44DA23}"
22+
EndProject
23+
Global
24+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
25+
Debug|Any CPU = Debug|Any CPU
26+
Release|Any CPU = Release|Any CPU
27+
EndGlobalSection
28+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
29+
{4B6E5DCB-C16F-4880-AA97-BC5D01959E49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30+
{4B6E5DCB-C16F-4880-AA97-BC5D01959E49}.Debug|Any CPU.Build.0 = Debug|Any CPU
31+
{4B6E5DCB-C16F-4880-AA97-BC5D01959E49}.Release|Any CPU.ActiveCfg = Release|Any CPU
32+
{4B6E5DCB-C16F-4880-AA97-BC5D01959E49}.Release|Any CPU.Build.0 = Release|Any CPU
33+
{39597E4B-23B4-4A6A-A71B-FFBE131A94D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34+
{39597E4B-23B4-4A6A-A71B-FFBE131A94D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
35+
{39597E4B-23B4-4A6A-A71B-FFBE131A94D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
36+
{39597E4B-23B4-4A6A-A71B-FFBE131A94D6}.Release|Any CPU.Build.0 = Release|Any CPU
37+
{973ECB19-5301-4191-9D93-3BEC9D2FCCF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38+
{973ECB19-5301-4191-9D93-3BEC9D2FCCF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
39+
{973ECB19-5301-4191-9D93-3BEC9D2FCCF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
40+
{973ECB19-5301-4191-9D93-3BEC9D2FCCF6}.Release|Any CPU.Build.0 = Release|Any CPU
41+
{6ED65535-CCC9-438E-80D4-1598FB572512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42+
{6ED65535-CCC9-438E-80D4-1598FB572512}.Debug|Any CPU.Build.0 = Debug|Any CPU
43+
{6ED65535-CCC9-438E-80D4-1598FB572512}.Release|Any CPU.ActiveCfg = Release|Any CPU
44+
{6ED65535-CCC9-438E-80D4-1598FB572512}.Release|Any CPU.Build.0 = Release|Any CPU
45+
{2443A7B5-99D5-40EA-9501-CCE80FC8951A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46+
{2443A7B5-99D5-40EA-9501-CCE80FC8951A}.Debug|Any CPU.Build.0 = Debug|Any CPU
47+
{2443A7B5-99D5-40EA-9501-CCE80FC8951A}.Release|Any CPU.ActiveCfg = Release|Any CPU
48+
{2443A7B5-99D5-40EA-9501-CCE80FC8951A}.Release|Any CPU.Build.0 = Release|Any CPU
49+
{FE26E5E2-B692-4FF2-86BE-E3E3DC44DA23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50+
{FE26E5E2-B692-4FF2-86BE-E3E3DC44DA23}.Debug|Any CPU.Build.0 = Debug|Any CPU
51+
{FE26E5E2-B692-4FF2-86BE-E3E3DC44DA23}.Release|Any CPU.ActiveCfg = Release|Any CPU
52+
{FE26E5E2-B692-4FF2-86BE-E3E3DC44DA23}.Release|Any CPU.Build.0 = Release|Any CPU
53+
EndGlobalSection
54+
GlobalSection(SolutionProperties) = preSolution
55+
HideSolutionNode = FALSE
56+
EndGlobalSection
57+
GlobalSection(ExtensibilityGlobals) = postSolution
58+
SolutionGuid = {1D8D22CA-6A4F-4F12-87D2-62754F69FF39}
59+
EndGlobalSection
60+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using Xunit;
3+
4+
namespace XUnitTestProject1
5+
{
6+
public class UnitTest1
7+
{
8+
[Fact]
9+
public void Test1()
10+
{
11+
new ClassLibrary1.Class1().Method();
12+
}
13+
}
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="coverlet.msbuild" Version="2.6.3">
11+
<PrivateAssets>all</PrivateAssets>
12+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13+
</PackageReference>
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
15+
<PackageReference Include="xunit" Version="2.4.0" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj" />
21+
</ItemGroup>
22+
23+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using Xunit;
3+
4+
namespace XUnitTestProject2
5+
{
6+
public class UnitTest2
7+
{
8+
[Fact]
9+
public void Test2()
10+
{
11+
new ClassLibrary2.Class2().Method();
12+
}
13+
}
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="coverlet.msbuild" Version="2.6.3">
11+
<PrivateAssets>all</PrivateAssets>
12+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13+
</PackageReference>
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
15+
<PackageReference Include="xunit" Version="2.4.0" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<ProjectReference Include="..\ClassLibrary2\ClassLibrary2.csproj" />
21+
</ItemGroup>
22+
23+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using Xunit;
3+
4+
namespace XUnitTestProject3
5+
{
6+
public class UnitTest3
7+
{
8+
[Fact]
9+
public void Test3()
10+
{
11+
new ClassLibrary3.Class3().Method();
12+
}
13+
}
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="coverlet.msbuild" Version="2.6.3">
11+
<PrivateAssets>all</PrivateAssets>
12+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13+
</PackageReference>
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
15+
<PackageReference Include="xunit" Version="2.4.0" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<ProjectReference Include="..\ClassLibrary3\ClassLibrary3.csproj" />
21+
</ItemGroup>
22+
23+
</Project>

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ Coverlet generates code coverage information by going through the following proc
9999

100100
_Note: The assembly you'd like to get coverage for must be different from the assembly that contains the tests_
101101

102+
## Are you in trouble with some feature? Check on [examples](Documentation/Examples.md)!
103+
102104
## Cake Add-In
103105

104106
If you're using [Cake Build](https://cakebuild.net) for your build script you can use the [Cake.Coverlet](https://github.com/Romanx/Cake.Coverlet) add-in to provide you extensions to dotnet test for passing Coverlet arguments in a strongly typed manner.

0 commit comments

Comments
 (0)