Skip to content

Commit 4f73e10

Browse files
committed
migrate to Microsoft.Testing.Platform v2
1 parent 192d4e1 commit 4f73e10

File tree

7 files changed

+43
-39
lines changed

7 files changed

+43
-39
lines changed

.github/workflows/new-cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ jobs:
5353
run: dotnet format ./new-cli --exclude ~/.nuget/packages --verify-no-changes
5454
-
5555
name: Test 'new-cli' solution
56-
run: dotnet test ./new-cli --no-build --verbosity normal
56+
run: dotnet test --solution ./new-cli/GitVersion.slnx --no-build --verbosity normal

build/build/Tasks/Test/UnitTest.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,29 @@ private static void TestProjectForTarget(BuildContext context, FilePath project,
6969
var projectName = $"{project.GetFilenameWithoutExtension()}.net{framework}";
7070
var settings = new DotNetTestSettings
7171
{
72+
PathType = DotNetTestPathType.Project,
7273
Framework = $"net{framework}",
7374
NoBuild = true,
7475
NoRestore = true,
7576
Configuration = context.MsBuildConfiguration,
76-
TestAdapterPath = new(".")
7777
};
7878

7979
var resultsPath = context.MakeAbsolute(testResultsPath.CombineWithFilePath($"{projectName}.results.xml"));
80-
settings.Loggers = [$"junit;LogFilePath={resultsPath}"];
80+
settings.WithArgumentCustomization(args => args
81+
.Append("--report-spekt-junit")
82+
.Append("--report-spekt-junit-filename").AppendQuoted(resultsPath.FullPath)
83+
);
8184

82-
var coverletSettings = new CoverletSettings
83-
{
84-
CollectCoverage = true,
85-
CoverletOutputFormat = CoverletOutputFormat.cobertura,
86-
CoverletOutputDirectory = testResultsPath,
87-
CoverletOutputName = $"{projectName}.coverage.xml",
88-
Exclude = ["[GitVersion*.Tests]*", "[GitTools.Testing]*"]
89-
};
85+
context.DotNetTest(project.FullPath, settings);
86+
// var coverletSettings = new CoverletSettings
87+
// {
88+
// CollectCoverage = true,
89+
// CoverletOutputFormat = CoverletOutputFormat.cobertura,
90+
// CoverletOutputDirectory = testResultsPath,
91+
// CoverletOutputName = $"{projectName}.coverage.xml",
92+
// Exclude = ["[GitVersion*.Tests]*", "[GitTools.Testing]*"]
93+
// };
9094

91-
context.DotNetTest(project.FullPath, settings, coverletSettings);
95+
// context.DotNetTest(project.FullPath, settings, coverletSettings);
9296
}
9397
}

global.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
2-
"projects": [
3-
"build",
4-
"new-cli",
5-
"src"
6-
],
7-
"sdk": {
8-
"version": "10.0.102"
9-
}
2+
"projects": [
3+
"build",
4+
"new-cli",
5+
"src"
6+
],
7+
"sdk": {
8+
"version": "10.0.102"
9+
},
10+
"test": {
11+
"runner": "Microsoft.Testing.Platform"
12+
}
1013
}

new-cli/GitVersion.Cli.Generator.Tests/GitVersion.Cli.Generator.Tests.csproj

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<!-- Enable the NUnit runner, this is an opt-in feature -->
5-
<EnableNUnitRunner>true</EnableNUnitRunner>
6-
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
7-
8-
<!--
9-
Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
10-
For more information, visit https://learn.microsoft.com/dotnet/core/testing/microsoft-testing-platform-integration-dotnet-test#show-failure-per-test
11-
-->
12-
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
13-
144
<OutputType>Exe</OutputType>
155
<RootNamespace>GitVersion.Cli.Generator.Tests</RootNamespace>
166
<IsPackable>false</IsPackable>
7+
8+
<EnableNUnitRunner>true</EnableNUnitRunner>
179
</PropertyGroup>
1810

1911
<ItemGroup>

src/Directory.Build.props

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@
3333
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
3434

3535
<IsUnitTestProject>false</IsUnitTestProject>
36-
<IsUnitTestProject Condition="$(MSBuildProjectName.EndsWith('.Tests')) or $(MSBuildProjectName.EndsWith('.Testing'))">true</IsUnitTestProject>
36+
<IsUnitTestProject Condition="$(MSBuildProjectName.EndsWith('.Tests'))">true</IsUnitTestProject>
3737

3838
<DisableAnalyzers>false</DisableAnalyzers>
3939
<DisableApiAnalyzers>false</DisableApiAnalyzers>
4040
<DisableApiAnalyzers Condition=" '$(IsUnitTestProject)' == 'true' ">true</DisableApiAnalyzers>
4141
<DisableApiAnalyzers Condition="$(MSBuildProjectName.EndsWith('.Schema')) == 'true'">true</DisableApiAnalyzers>
42+
<DisableApiAnalyzers Condition="$(MSBuildProjectName.EndsWith('.Testing')) == 'true'">true</DisableApiAnalyzers>
43+
</PropertyGroup>
44+
45+
<PropertyGroup Condition=" '$(IsUnitTestProject)' == 'true' ">
46+
<OutputType>Exe</OutputType>
47+
<EnableNUnitRunner>true</EnableNUnitRunner>
4248
</PropertyGroup>
4349

4450
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
@@ -61,11 +67,9 @@
6167
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6268
</PackageReference>
6369
</ItemGroup>
64-
<ItemGroup Condition=" '$(IsUnitTestProject)' == 'true' ">
70+
<ItemGroup Condition=" '$(IsUnitTestProject)' == 'true' or $(MSBuildProjectName.EndsWith('.Testing')) ">
6571
<PackageReference Include="Microsoft.NET.Test.Sdk" />
66-
6772
<PackageReference Include="NSubstitute" />
68-
6973
<PackageReference Include="NUnit" />
7074
<PackageReference Include="NUnit3TestAdapter" />
7175
<PackageReference Include="JunitXml.TestLogger" />
@@ -81,13 +85,13 @@
8185
</PackageReference>
8286

8387
</ItemGroup>
84-
<ItemGroup Condition=" '$(IsUnitTestProject)' == 'true' and $(MSBuildProjectName.EndsWith('.Tests'))">
88+
<ItemGroup Condition=" '$(IsUnitTestProject)' == 'true' ">
8589
<ProjectReference Include="..\GitVersion.Testing\GitVersion.Testing.csproj" />
8690

87-
<Using Include="GitVersion.Testing" />
8891
<Using Include="NSubstitute" />
8992
<Using Include="NUnit.Framework" />
9093
<Using Include="Shouldly" />
94+
<Using Include="GitVersion.Testing" />
9195
</ItemGroup>
9296

9397
<ItemGroup>

src/Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<!-- common packages -->
77
<PackageVersion Include="JsonSchema.Net" Version="7.3.4" />
88
<PackageVersion Include="LibGit2Sharp" Version="0.31.0" />
9-
<PackageVersion Include="Microsoft.Build.Tasks.Core" Version="17.14.28" />
9+
<PackageVersion Include="Microsoft.Build.Tasks.Core" Version="18.0.2" />
1010
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
1111
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="5.0.0" />
1212
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" />
@@ -20,10 +20,10 @@
2020
<PackageVersion Include="Roslynator.Analyzers" Version="4.15.0" />
2121
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.15.0" />
2222
<!-- specific packages -->
23-
<PackageVersion Include="Buildalyzer" Version="7.1.0" />
23+
<PackageVersion Include="Buildalyzer" Version="8.0.0" />
2424
<PackageVersion Include="JsonSchema.Net.Generation" Version="6.0.0" />
2525
<PackageVersion Include="JunitXml.TestLogger" Version="8.0.0" />
26-
<PackageVersion Include="MSBuild.ProjectCreation" Version="16.1.0" />
26+
<PackageVersion Include="MSBuild.ProjectCreation" Version="17.0.1" />
2727
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.0" />
2828
<PackageVersion Include="Microsoft.Build" Version="18.0.2" />
2929
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="18.0.2" />

src/GitVersion.Testing/GitVersion.Testing.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3+
<OutputType>Library</OutputType>
34
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
45
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
56
</PropertyGroup>

0 commit comments

Comments
 (0)