diff --git a/Documentation/Examples.md b/Documentation/Examples.md new file mode 100644 index 0000000..5e10cad --- /dev/null +++ b/Documentation/Examples.md @@ -0,0 +1,4 @@ +# Examples + +## MSBuild Integration +* Use `/p:MergeWith` feature `Documentation/Examples/MSBuild/MergeWith/MergeWith.sln` diff --git a/Documentation/Examples/MSBuild/MergeWith/ClassLibrary1/Class1.cs b/Documentation/Examples/MSBuild/MergeWith/ClassLibrary1/Class1.cs new file mode 100644 index 0000000..289865e --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/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/MergeWith/ClassLibrary1/ClassLibrary1.csproj b/Documentation/Examples/MSBuild/MergeWith/ClassLibrary1/ClassLibrary1.csproj new file mode 100644 index 0000000..9f5c4f4 --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/ClassLibrary1/ClassLibrary1.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/Documentation/Examples/MSBuild/MergeWith/ClassLibrary2/Class2.cs b/Documentation/Examples/MSBuild/MergeWith/ClassLibrary2/Class2.cs new file mode 100644 index 0000000..aa93f55 --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/ClassLibrary2/Class2.cs @@ -0,0 +1,12 @@ +using System; + +namespace ClassLibrary2 +{ + public class Class2 + { + public int Method() + { + return 42; + } + } +} diff --git a/Documentation/Examples/MSBuild/MergeWith/ClassLibrary2/ClassLibrary2.csproj b/Documentation/Examples/MSBuild/MergeWith/ClassLibrary2/ClassLibrary2.csproj new file mode 100644 index 0000000..9f5c4f4 --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/ClassLibrary2/ClassLibrary2.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/Documentation/Examples/MSBuild/MergeWith/ClassLibrary3/Class3.cs b/Documentation/Examples/MSBuild/MergeWith/ClassLibrary3/Class3.cs new file mode 100644 index 0000000..872291e --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/ClassLibrary3/Class3.cs @@ -0,0 +1,12 @@ +using System; + +namespace ClassLibrary3 +{ + public class Class3 + { + public int Method() + { + return 42; + } + } +} diff --git a/Documentation/Examples/MSBuild/MergeWith/ClassLibrary3/ClassLibrary3.csproj b/Documentation/Examples/MSBuild/MergeWith/ClassLibrary3/ClassLibrary3.csproj new file mode 100644 index 0000000..9f5c4f4 --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/ClassLibrary3/ClassLibrary3.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/Documentation/Examples/MSBuild/MergeWith/MergeWith.md b/Documentation/Examples/MSBuild/MergeWith/MergeWith.md new file mode 100644 index 0000000..ef5b662 --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/MergeWith.md @@ -0,0 +1,10 @@ +**Run from solution root sln** + +To merge report togheter you need to run separate test and merge in one `json` format file. +Last command will join and create final needed format file. + +``` +dotnet test XUnitTestProject1\XUnitTestProject1.csproj /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ +dotnet test XUnitTestProject2\XUnitTestProject2.csproj /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json" +dotnet test XUnitTestProject3\XUnitTestProject3.csproj /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json" /p:CoverletOutputFormat="opencover" +``` \ No newline at end of file diff --git a/Documentation/Examples/MSBuild/MergeWith/MergeWith.sln b/Documentation/Examples/MSBuild/MergeWith/MergeWith.sln new file mode 100644 index 0000000..b834c84 --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/MergeWith.sln @@ -0,0 +1,60 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29230.61 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{4B6E5DCB-C16F-4880-AA97-BC5D01959E49}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTestProject1", "XUnitTestProject1\XUnitTestProject1.csproj", "{39597E4B-23B4-4A6A-A71B-FFBE131A94D6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary2", "ClassLibrary2\ClassLibrary2.csproj", "{973ECB19-5301-4191-9D93-3BEC9D2FCCF6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTestProject2", "XUnitTestProject2\XUnitTestProject2.csproj", "{6ED65535-CCC9-438E-80D4-1598FB572512}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5F5E20F4-E34C-48BB-906D-65CF1B55A6AA}" + ProjectSection(SolutionItems) = preProject + MergeWith.md = MergeWith.md + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary3", "ClassLibrary3\ClassLibrary3.csproj", "{2443A7B5-99D5-40EA-9501-CCE80FC8951A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTestProject3", "XUnitTestProject3\XUnitTestProject3.csproj", "{FE26E5E2-B692-4FF2-86BE-E3E3DC44DA23}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4B6E5DCB-C16F-4880-AA97-BC5D01959E49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4B6E5DCB-C16F-4880-AA97-BC5D01959E49}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4B6E5DCB-C16F-4880-AA97-BC5D01959E49}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4B6E5DCB-C16F-4880-AA97-BC5D01959E49}.Release|Any CPU.Build.0 = Release|Any CPU + {39597E4B-23B4-4A6A-A71B-FFBE131A94D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39597E4B-23B4-4A6A-A71B-FFBE131A94D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {39597E4B-23B4-4A6A-A71B-FFBE131A94D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39597E4B-23B4-4A6A-A71B-FFBE131A94D6}.Release|Any CPU.Build.0 = Release|Any CPU + {973ECB19-5301-4191-9D93-3BEC9D2FCCF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {973ECB19-5301-4191-9D93-3BEC9D2FCCF6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {973ECB19-5301-4191-9D93-3BEC9D2FCCF6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {973ECB19-5301-4191-9D93-3BEC9D2FCCF6}.Release|Any CPU.Build.0 = Release|Any CPU + {6ED65535-CCC9-438E-80D4-1598FB572512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6ED65535-CCC9-438E-80D4-1598FB572512}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6ED65535-CCC9-438E-80D4-1598FB572512}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6ED65535-CCC9-438E-80D4-1598FB572512}.Release|Any CPU.Build.0 = Release|Any CPU + {2443A7B5-99D5-40EA-9501-CCE80FC8951A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2443A7B5-99D5-40EA-9501-CCE80FC8951A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2443A7B5-99D5-40EA-9501-CCE80FC8951A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2443A7B5-99D5-40EA-9501-CCE80FC8951A}.Release|Any CPU.Build.0 = Release|Any CPU + {FE26E5E2-B692-4FF2-86BE-E3E3DC44DA23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE26E5E2-B692-4FF2-86BE-E3E3DC44DA23}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE26E5E2-B692-4FF2-86BE-E3E3DC44DA23}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE26E5E2-B692-4FF2-86BE-E3E3DC44DA23}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1D8D22CA-6A4F-4F12-87D2-62754F69FF39} + EndGlobalSection +EndGlobal diff --git a/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject1/UnitTest1.cs b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject1/UnitTest1.cs new file mode 100644 index 0000000..5eeb5df --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/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/MergeWith/XUnitTestProject1/XUnitTestProject1.csproj b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject1/XUnitTestProject1.csproj new file mode 100644 index 0000000..6e65e4d --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject1/XUnitTestProject1.csproj @@ -0,0 +1,23 @@ + + + + netcoreapp2.0 + + false + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + diff --git a/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject2/UnitTest2.cs b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject2/UnitTest2.cs new file mode 100644 index 0000000..c6ce4b1 --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject2/UnitTest2.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace XUnitTestProject2 +{ + public class UnitTest2 + { + [Fact] + public void Test2() + { + new ClassLibrary2.Class2().Method(); + } + } +} diff --git a/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject2/XUnitTestProject2.csproj b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject2/XUnitTestProject2.csproj new file mode 100644 index 0000000..aaea2d4 --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject2/XUnitTestProject2.csproj @@ -0,0 +1,23 @@ + + + + netcoreapp2.0 + + false + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + diff --git a/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject3/UnitTest3.cs b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject3/UnitTest3.cs new file mode 100644 index 0000000..482d9ed --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject3/UnitTest3.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace XUnitTestProject3 +{ + public class UnitTest3 + { + [Fact] + public void Test3() + { + new ClassLibrary3.Class3().Method(); + } + } +} diff --git a/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject3/XUnitTestProject3.csproj b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject3/XUnitTestProject3.csproj new file mode 100644 index 0000000..6f36de3 --- /dev/null +++ b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject3/XUnitTestProject3.csproj @@ -0,0 +1,23 @@ + + + + netcoreapp2.0 + + false + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + diff --git a/README.md b/README.md index 583a3e2..9346f17 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,8 @@ Coverlet generates code coverage information by going through the following proc _Note: The assembly you'd like to get coverage for must be different from the assembly that contains the tests_ +## Are you in trouble with some feature? Check on [examples](Documentation/Examples.md)! + ## Cake Add-In 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.