From 45d8d4ee42757dffc8c53f9b50f15b2b4ae26c17 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Mon, 9 Dec 2019 17:07:48 +0100 Subject: [PATCH] Add vstest integration example (#651) Add vstest integration example --- Documentation/Examples.md | 4 ++ .../MergeWith/{MergeWith.md => HowTo.md} | 0 .../VSTest/HelloWorld/ClassLibrary1/Class1.cs | 12 ++++ .../ClassLibrary1/ClassLibrary1.csproj | 7 +++ .../Examples/VSTest/HelloWorld/HelloWorld.sln | 56 +++++++++++++++++++ .../Examples/VSTest/HelloWorld/HowTo.md | 11 ++++ .../HelloWorld/XUnitTestProject1/UnitTest1.cs | 14 +++++ .../XUnitTestProject1.csproj | 24 ++++++++ .../XUnitTestProject1/runsettings.xml | 12 ++++ 9 files changed, 140 insertions(+) rename Documentation/Examples/MSBuild/MergeWith/{MergeWith.md => HowTo.md} (100%) create mode 100644 Documentation/Examples/VSTest/HelloWorld/ClassLibrary1/Class1.cs create mode 100644 Documentation/Examples/VSTest/HelloWorld/ClassLibrary1/ClassLibrary1.csproj create mode 100644 Documentation/Examples/VSTest/HelloWorld/HelloWorld.sln create mode 100644 Documentation/Examples/VSTest/HelloWorld/HowTo.md create mode 100644 Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/UnitTest1.cs create mode 100644 Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/XUnitTestProject1.csproj create mode 100644 Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/runsettings.xml diff --git a/Documentation/Examples.md b/Documentation/Examples.md index 5e10cad..391f2de 100644 --- a/Documentation/Examples.md +++ b/Documentation/Examples.md @@ -2,3 +2,7 @@ ## MSBuild Integration * Use `/p:MergeWith` feature `Documentation/Examples/MSBuild/MergeWith/MergeWith.sln` + +## VSTest Integration +* 'HelloWorld' sample `Documentation/Examples/VSTest/HelloWorld/HelloWorld.sln` + diff --git a/Documentation/Examples/MSBuild/MergeWith/MergeWith.md b/Documentation/Examples/MSBuild/MergeWith/HowTo.md similarity index 100% rename from Documentation/Examples/MSBuild/MergeWith/MergeWith.md rename to Documentation/Examples/MSBuild/MergeWith/HowTo.md diff --git a/Documentation/Examples/VSTest/HelloWorld/ClassLibrary1/Class1.cs b/Documentation/Examples/VSTest/HelloWorld/ClassLibrary1/Class1.cs new file mode 100644 index 0000000..289865e --- /dev/null +++ b/Documentation/Examples/VSTest/HelloWorld/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/HelloWorld/ClassLibrary1/ClassLibrary1.csproj b/Documentation/Examples/VSTest/HelloWorld/ClassLibrary1/ClassLibrary1.csproj new file mode 100644 index 0000000..9f5c4f4 --- /dev/null +++ b/Documentation/Examples/VSTest/HelloWorld/ClassLibrary1/ClassLibrary1.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/Documentation/Examples/VSTest/HelloWorld/HelloWorld.sln b/Documentation/Examples/VSTest/HelloWorld/HelloWorld.sln new file mode 100644 index 0000000..d471958 --- /dev/null +++ b/Documentation/Examples/VSTest/HelloWorld/HelloWorld.sln @@ -0,0 +1,56 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29521.150 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XUnitTestProject1", "XUnitTestProject1\XUnitTestProject1.csproj", "{26290689-7824-4A08-89B0-6C2F44085D7C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6078A839-FBD0-4135-A552-7A7A0D80A587}" + ProjectSection(SolutionItems) = preProject + 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 + {26290689-7824-4A08-89B0-6C2F44085D7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {26290689-7824-4A08-89B0-6C2F44085D7C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {26290689-7824-4A08-89B0-6C2F44085D7C}.Debug|x64.ActiveCfg = Debug|Any CPU + {26290689-7824-4A08-89B0-6C2F44085D7C}.Debug|x64.Build.0 = Debug|Any CPU + {26290689-7824-4A08-89B0-6C2F44085D7C}.Debug|x86.ActiveCfg = Debug|Any CPU + {26290689-7824-4A08-89B0-6C2F44085D7C}.Debug|x86.Build.0 = Debug|Any CPU + {26290689-7824-4A08-89B0-6C2F44085D7C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {26290689-7824-4A08-89B0-6C2F44085D7C}.Release|Any CPU.Build.0 = Release|Any CPU + {26290689-7824-4A08-89B0-6C2F44085D7C}.Release|x64.ActiveCfg = Release|Any CPU + {26290689-7824-4A08-89B0-6C2F44085D7C}.Release|x64.Build.0 = Release|Any CPU + {26290689-7824-4A08-89B0-6C2F44085D7C}.Release|x86.ActiveCfg = Release|Any CPU + {26290689-7824-4A08-89B0-6C2F44085D7C}.Release|x86.Build.0 = Release|Any CPU + {E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Debug|x64.ActiveCfg = Debug|Any CPU + {E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Debug|x64.Build.0 = Debug|Any CPU + {E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Debug|x86.ActiveCfg = Debug|Any CPU + {E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Debug|x86.Build.0 = Debug|Any CPU + {E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Release|Any CPU.Build.0 = Release|Any CPU + {E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Release|x64.ActiveCfg = Release|Any CPU + {E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Release|x64.Build.0 = Release|Any CPU + {E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Release|x86.ActiveCfg = Release|Any CPU + {E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {070BB83A-CEA3-44DF-B61C-CA6225F66E29} + EndGlobalSection +EndGlobal diff --git a/Documentation/Examples/VSTest/HelloWorld/HowTo.md b/Documentation/Examples/VSTest/HelloWorld/HowTo.md new file mode 100644 index 0000000..548105f --- /dev/null +++ b/Documentation/Examples/VSTest/HelloWorld/HowTo.md @@ -0,0 +1,11 @@ +**Run from XUnitTestProject1 folder** + +``` +dotnet test --collect:"XPlat Code Coverage" +``` + +With custom runsettings file + +``` +dotnet test --collect:"XPlat Code Coverage" --settings runsettings.xml +``` \ No newline at end of file diff --git a/Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/UnitTest1.cs b/Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/UnitTest1.cs new file mode 100644 index 0000000..5eeb5df --- /dev/null +++ b/Documentation/Examples/VSTest/HelloWorld/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/HelloWorld/XUnitTestProject1/XUnitTestProject1.csproj b/Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/XUnitTestProject1.csproj new file mode 100644 index 0000000..b34ccaa --- /dev/null +++ b/Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/XUnitTestProject1.csproj @@ -0,0 +1,24 @@ + + + + netcoreapp2.0 + + false + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/runsettings.xml b/Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/runsettings.xml new file mode 100644 index 0000000..10551de --- /dev/null +++ b/Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/runsettings.xml @@ -0,0 +1,12 @@ + + + + + + + lcov,cobertura + + + + + \ No newline at end of file