Skip to content

Commit 45d8d4e

Browse files
Add vstest integration example (#651)
Add vstest integration example
1 parent 6336e58 commit 45d8d4e

File tree

9 files changed

+140
-0
lines changed

9 files changed

+140
-0
lines changed

Documentation/Examples.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22

33
## MSBuild Integration
44
* Use `/p:MergeWith` feature `Documentation/Examples/MSBuild/MergeWith/MergeWith.sln`
5+
6+
## VSTest Integration
7+
* 'HelloWorld' sample `Documentation/Examples/VSTest/HelloWorld/HelloWorld.sln`
8+
File renamed without changes.
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: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29521.150
5+
MinimumVisualStudioVersion = 15.0.26124.0
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XUnitTestProject1", "XUnitTestProject1\XUnitTestProject1.csproj", "{26290689-7824-4A08-89B0-6C2F44085D7C}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6078A839-FBD0-4135-A552-7A7A0D80A587}"
11+
ProjectSection(SolutionItems) = preProject
12+
HowTo.md = HowTo.md
13+
EndProjectSection
14+
EndProject
15+
Global
16+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
17+
Debug|Any CPU = Debug|Any CPU
18+
Debug|x64 = Debug|x64
19+
Debug|x86 = Debug|x86
20+
Release|Any CPU = Release|Any CPU
21+
Release|x64 = Release|x64
22+
Release|x86 = Release|x86
23+
EndGlobalSection
24+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
25+
{26290689-7824-4A08-89B0-6C2F44085D7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{26290689-7824-4A08-89B0-6C2F44085D7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{26290689-7824-4A08-89B0-6C2F44085D7C}.Debug|x64.ActiveCfg = Debug|Any CPU
28+
{26290689-7824-4A08-89B0-6C2F44085D7C}.Debug|x64.Build.0 = Debug|Any CPU
29+
{26290689-7824-4A08-89B0-6C2F44085D7C}.Debug|x86.ActiveCfg = Debug|Any CPU
30+
{26290689-7824-4A08-89B0-6C2F44085D7C}.Debug|x86.Build.0 = Debug|Any CPU
31+
{26290689-7824-4A08-89B0-6C2F44085D7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
32+
{26290689-7824-4A08-89B0-6C2F44085D7C}.Release|Any CPU.Build.0 = Release|Any CPU
33+
{26290689-7824-4A08-89B0-6C2F44085D7C}.Release|x64.ActiveCfg = Release|Any CPU
34+
{26290689-7824-4A08-89B0-6C2F44085D7C}.Release|x64.Build.0 = Release|Any CPU
35+
{26290689-7824-4A08-89B0-6C2F44085D7C}.Release|x86.ActiveCfg = Release|Any CPU
36+
{26290689-7824-4A08-89B0-6C2F44085D7C}.Release|x86.Build.0 = Release|Any CPU
37+
{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38+
{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
39+
{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Debug|x64.ActiveCfg = Debug|Any CPU
40+
{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Debug|x64.Build.0 = Debug|Any CPU
41+
{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Debug|x86.ActiveCfg = Debug|Any CPU
42+
{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Debug|x86.Build.0 = Debug|Any CPU
43+
{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
44+
{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Release|Any CPU.Build.0 = Release|Any CPU
45+
{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Release|x64.ActiveCfg = Release|Any CPU
46+
{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Release|x64.Build.0 = Release|Any CPU
47+
{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Release|x86.ActiveCfg = Release|Any CPU
48+
{E3BAA878-1CFC-4F94-B962-BAD20CEBFFAB}.Release|x86.Build.0 = Release|Any CPU
49+
EndGlobalSection
50+
GlobalSection(SolutionProperties) = preSolution
51+
HideSolutionNode = FALSE
52+
EndGlobalSection
53+
GlobalSection(ExtensibilityGlobals) = postSolution
54+
SolutionGuid = {070BB83A-CEA3-44DF-B61C-CA6225F66E29}
55+
EndGlobalSection
56+
EndGlobal
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
**Run from XUnitTestProject1 folder**
2+
3+
```
4+
dotnet test --collect:"XPlat Code Coverage"
5+
```
6+
7+
With custom runsettings file
8+
9+
```
10+
dotnet test --collect:"XPlat Code Coverage" --settings runsettings.xml
11+
```
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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
<!--To update with official release when will be available-->
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0-preview-20191115-01" />
12+
<PackageReference Include="xunit" Version="2.4.0" />
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
14+
<PackageReference Include="coverlet.collector" Version="1.1.0">
15+
<PrivateAssets>all</PrivateAssets>
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
</PackageReference>
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj" />
22+
</ItemGroup>
23+
24+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<RunSettings>
3+
<DataCollectionRunSettings>
4+
<DataCollectors>
5+
<DataCollector friendlyName="XPlat code coverage">
6+
<Configuration>
7+
<Format>lcov,cobertura</Format>
8+
</Configuration>
9+
</DataCollector>
10+
</DataCollectors>
11+
</DataCollectionRunSettings>
12+
</RunSettings>

0 commit comments

Comments
 (0)