Skip to content

Commit 0b8fb79

Browse files
EvangelinkCopilotJamieMagee
authored
Use MSTest.Sdk and opt-in to MTP (#1680)
* Use MSTest.Sdk and opt-in to MTP * Update .github/workflows/build.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/Microsoft.ComponentDetection.TestsUtilities/Microsoft.ComponentDetection.TestsUtilities.csproj Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix Directory.Build.props --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Jamie Magee <jamagee@microsoft.com>
1 parent c5ed916 commit 0b8fb79

File tree

9 files changed

+17
-30
lines changed

9 files changed

+17
-30
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ jobs:
4141
run: dotnet build --no-restore --configuration Debug
4242

4343
- name: Run tests
44-
run: dotnet test --no-build --configuration Debug --collect:"Code Coverage;Format=cobertura;CoverageFileName=coverage.cobertura.xml"
44+
# The '--' separator forwards options to the Microsoft Testing Platform runner.
45+
# After upgrading to .NET 10 SDK, these can be passed directly without '--'.
46+
run: dotnet test --no-build --configuration Debug -- --coverage --coverage-output-format cobertura
4547

4648
- name: Upload coverage reports to Codecov
4749
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2

Directory.Packages.props

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
<PackageVersion Include="morelinq" Version="4.4.0" />
2424
<PackageVersion Include="MSTest.TestFramework" Version="4.1.0" />
2525
<PackageVersion Include="MSTest.Analyzers" Version="4.1.0" />
26-
<PackageVersion Include="MSTest.TestAdapter" Version="4.1.0" />
27-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
2826
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
2927
<PackageVersion Include="Newtonsoft.Json.Schema" Version="4.0.1" />
3028
<PackageVersion Include="NuGet.ProjectModel" Version="7.3.0" />

global.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"sdk": {
33
"version": "8.0.418",
44
"rollForward": "latestFeature"
5+
},
6+
"msbuild-sdks": {
7+
"MSTest.Sdk": "4.1.0"
58
}
69
}

test/Directory.Build.props

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44

55
<PropertyGroup>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
7+
<!-- Opts into running tests via Microsoft Testing Platform instead of VSTest when using 'dotnet test'.
8+
When migrating to .NET 10 SDK, this should be removed and opt-in should be done via global.json instead.
9+
https://learn.microsoft.com/dotnet/core/testing/unit-testing-mstest-runner-intro#dotnet-test-integration -->
10+
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
11+
<!-- Shows the failed test output inline when using 'dotnet test' with Microsoft Testing Platform. -->
12+
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
713
</PropertyGroup>
814

915
<ItemGroup Label="Package References">
10-
<PackageReference Include="MSTest.TestFramework"/>
11-
<PackageReference Include="MSTest.Analyzers "/>
1216
<PackageReference Include="Moq"/>
1317
<PackageReference Include="AwesomeAssertions"/>
1418
<PackageReference Include="Faker.net"/>

test/Microsoft.ComponentDetection.Common.Tests/Microsoft.ComponentDetection.Common.Tests.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="MSTest.Sdk">
22

33
<ItemGroup Label="Project References">
44
<ProjectReference Include="..\Microsoft.ComponentDetection.TestsUtilities\Microsoft.ComponentDetection.TestsUtilities.csproj" />
@@ -9,8 +9,6 @@
99
<PackageReference Include="AwesomeAssertions.Analyzers" PrivateAssets="all" />
1010
<PackageReference Include="Microsoft.Extensions.Logging" />
1111
<PackageReference Include="System.Threading.Tasks.Dataflow" />
12-
<PackageReference Include="MSTest.TestAdapter" />
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
1412
</ItemGroup>
1513

1614
<ItemGroup>

test/Microsoft.ComponentDetection.Contracts.Tests/Microsoft.ComponentDetection.Contracts.Tests.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="MSTest.Sdk">
22

33
<ItemGroup Label="Project References">
44
<ProjectReference Include="..\..\src\Microsoft.ComponentDetection.Contracts\Microsoft.ComponentDetection.Contracts.csproj" />
@@ -9,8 +9,6 @@
99
<PackageReference Include="System.Reactive" />
1010
<PackageReference Include="System.Threading.Tasks.Dataflow" />
1111
<PackageReference Include="packageurl-dotnet" />
12-
<PackageReference Include="MSTest.TestAdapter " />
13-
<PackageReference Include="Microsoft.NET.Test.Sdk " />
1412
<PackageReference Include="AwesomeAssertions.Analyzers" PrivateAssets="all" />
1513
</ItemGroup>
1614

test/Microsoft.ComponentDetection.Detectors.Tests/Microsoft.ComponentDetection.Detectors.Tests.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="MSTest.Sdk">
22

33
<ItemGroup Label="Project References">
44
<ProjectReference Include="..\..\src\Microsoft.ComponentDetection.Orchestrator\Microsoft.ComponentDetection.Orchestrator.csproj" />
@@ -16,8 +16,6 @@
1616
<PackageReference Include="packageurl-dotnet" />
1717
<PackageReference Include="Tomlyn.Signed" />
1818
<PackageReference Include="YamlDotNet" />
19-
<PackageReference Include="MSTest.TestAdapter" />
20-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
2119
</ItemGroup>
2220

2321
<ItemGroup>

test/Microsoft.ComponentDetection.Orchestrator.Tests/Microsoft.ComponentDetection.Orchestrator.Tests.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="MSTest.Sdk">
22

33
<ItemGroup Label="Project References">
44
<ProjectReference Include="..\..\src\Microsoft.ComponentDetection.Orchestrator\Microsoft.ComponentDetection.Orchestrator.csproj" />
@@ -11,8 +11,6 @@
1111
<PackageReference Include="Spectre.Console.Cli" />
1212
<PackageReference Include="Spectre.Console.Testing" />
1313
<PackageReference Include="System.Threading.Tasks.Dataflow" />
14-
<PackageReference Include="MSTest.TestAdapter " />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk " />
1614
<PackageReference Include="AwesomeAssertions.Analyzers" PrivateAssets="all" />
1715
</ItemGroup>
1816

test/Microsoft.ComponentDetection.VerificationTests/Microsoft.ComponentDetection.VerificationTests.csproj

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="MSTest.Sdk">
22

33
<PropertyGroup>
4-
<IsTestProject>true</IsTestProject>
5-
<TestProjectType>UnitTest</TestProjectType>
64
<ProjectGuid>{95c8e34e-5895-4c7e-8c7e-c300a114a1e5}</ProjectGuid>
7-
<OutputType>Library</OutputType>
85
<OutputPath>./bin</OutputPath>
96
<RootNamespace>Microsoft.ComponentDetection.VerificationTests</RootNamespace>
107
<AssemblyName>Microsoft.ComponentDetection.VerificationTests</AssemblyName>
118
<NoWarn>$(NoWarn);NU1504;NU1105</NoWarn>
129
</PropertyGroup>
1310

1411
<ItemGroup>
15-
<!--<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
16-
<PackageReference Include="MSTest.TestAdapter" Version="1.1.18" />
17-
<PackageReference Include="MSTest.TestFramework" Version="1.1.18" />
18-
IF TESTING LOCALLY, UNCOMMENT ABOVE AND COMMENT BELOW -->
19-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
20-
<PackageReference Include="MSTest.TestAdapter" />
21-
<PackageReference Include="MSTest.TestFramework" />
2212
<PackageReference Include="AwesomeAssertions" />
2313
<PackageReference Include="Microsoft.Extensions.Logging" />
24-
<PackageReference Include="MSTest.TestFramework"/>
25-
<PackageReference Include="MSTest.Analyzers "/>
2614
<PackageReference Include="Newtonsoft.Json.Schema" />
2715
<PackageReference Include="packageurl-dotnet" />
2816
<PackageReference Include="System.Threading.Tasks.Dataflow" />

0 commit comments

Comments
 (0)