Skip to content

Migrate to xunit v3 #1165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ FROM mcr.microsoft.com/dotnet/sdk:9.0.102-noble
# See https://github.com/dotnet/dotnet-docker/issues/2790 for a discussion on this, where the prioritized use case
# was *not* devcontainers, sadly.
ENV NUGET_XMLDOC_MODE=

# Install Node.js 18
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y nodejs
5 changes: 2 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="9.0.0" />
<PackageVersion Include="Validation" Version="2.5.51" />
<PackageVersion Include="Xunit.Combinatorial" Version="1.6.24" />
<PackageVersion Include="Xunit.SkippableFact" Version="1.5.23" />
<PackageVersion Include="Xunit.Combinatorial" Version="2.0.24" />
</ItemGroup>
<ItemGroup Label="Library.Template">
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.v3" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<!-- Put repo-specific GlobalPackageReference items in this group. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<OutputType>exe</OutputType>
<SignAssembly>false</SignAssembly>
<IsTestProject>true</IsTestProject>
<IsPackable>false</IsPackable>
Expand All @@ -18,7 +19,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Nerdbank.GitVersioning.LKG" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
</ItemGroup>

</Project>
12 changes: 6 additions & 6 deletions test/Nerdbank.GitVersioning.Tests/AssemblyInfoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class AssemblyInfoTest : IClassFixture<MSBuildFixture> // The MSBuildFixture throws PlatformNotSupportedException when run on mono.
{
[SkippableTheory(typeof(PlatformNotSupportedException))]
[Theory]
[InlineData(false)]
[InlineData(true)]
[InlineData(null)]
Expand Down Expand Up @@ -91,7 +91,7 @@ type internal ThisAssembly() =
Assert.Equal(expected, built);
}

[SkippableTheory(typeof(PlatformNotSupportedException))]
[Theory]
[InlineData(null, "MyRootNamespace")]
[InlineData("", "MyRootNamespace")]
[InlineData("MyCustomNamespace", null)]
Expand Down Expand Up @@ -152,7 +152,7 @@ type internal ThisAssembly() =
Assert.Equal(expected, built);
}

[SkippableTheory(typeof(PlatformNotSupportedException))]
[Theory]
[InlineData(false)]
[InlineData(true)]
[InlineData(null)]
Expand Down Expand Up @@ -228,7 +228,7 @@ internal static partial class ThisAssembly {{
Assert.Equal(expected, built);
}

[SkippableTheory(typeof(PlatformNotSupportedException))]
[Theory]
[InlineData(null, "MyRootNamespace")]
[InlineData("", "MyRootNamespace")]
[InlineData("MyCustomNamespace", null)]
Expand Down Expand Up @@ -286,7 +286,7 @@ internal static partial class ThisAssembly {{
Assert.Equal(expected, built);
}

[SkippableTheory(typeof(PlatformNotSupportedException))]
[Theory]
[InlineData(false)]
[InlineData(true)]
[InlineData(null)]
Expand Down Expand Up @@ -342,7 +342,7 @@ End Class
Assert.Equal(expected, built);
}

[SkippableTheory(typeof(PlatformNotSupportedException))]
[Theory]
[InlineData(null, "MyRootNamespace")]
[InlineData("", "MyRootNamespace")]
[InlineData("MyCustomNamespace", null)]
Expand Down
4 changes: 2 additions & 2 deletions test/Nerdbank.GitVersioning.Tests/BuildIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ public async Task AssemblyInfo_HasKeyData(string keyFile, bool delaySigned)
result.BuildResult.ProjectStateAfterBuild.GetPropertyValue("VersionSourceFile"))));
this.Logger.WriteLine(versionCsContent);

SyntaxTree sourceFile = CSharpSyntaxTree.ParseText(versionCsContent);
SyntaxNode syntaxTree = await sourceFile.GetRootAsync();
SyntaxTree sourceFile = CSharpSyntaxTree.ParseText(versionCsContent, cancellationToken: TestContext.Current.CancellationToken);
SyntaxNode syntaxTree = await sourceFile.GetRootAsync(TestContext.Current.CancellationToken);
IEnumerable<VariableDeclaratorSyntax> fields = syntaxTree.DescendantNodes().OfType<VariableDeclaratorSyntax>();

var publicKeyField = (LiteralExpressionSyntax)fields.SingleOrDefault(f => f.Identifier.ValueText == "PublicKey")?.Initializer.Value;
Expand Down
4 changes: 2 additions & 2 deletions test/Nerdbank.GitVersioning.Tests/GitContextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ public void SelectCommitByPartialId(bool fromPack, bool oddLength)
Assert.Equal(this.LibGit2Repository.Head.Tip.Sha, this.Context.GitCommitId);
}

[SkippableTheory]
[Theory]
[InlineData(4)]
[InlineData(7)]
[InlineData(8)]
[InlineData(11)]
public void GetShortUniqueCommitId(int length)
{
Skip.If(length < 7 && this.Context is Nerdbank.GitVersioning.LibGit2.LibGit2Context, "LibGit2Sharp never returns commit IDs with fewer than 7 characters.");
Assert.SkipWhen(length < 7 && this.Context is Nerdbank.GitVersioning.LibGit2.LibGit2Context, "LibGit2Sharp never returns commit IDs with fewer than 7 characters.");
Assert.Equal(this.Context.GitCommitId.Substring(0, length), this.Context.GetShortUniqueCommitId(length));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public void GetIdAsVersion_MigrationFromVersionTxtToJson()
public void TestBiggerRepo()
{
string testBiggerRepoPath = @"D:\git\Nerdbank.GitVersioning";
Skip.If(!Directory.Exists(testBiggerRepoPath), $"{testBiggerRepoPath} does not exist.");
Assert.SkipWhen(!Directory.Exists(testBiggerRepoPath), $"{testBiggerRepoPath} does not exist.");

using var largeRepo = new Repository(testBiggerRepoPath);
foreach (Commit commit in largeRepo.Head.Commits)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net9.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(TargetFrameworks);net472</TargetFrameworks>
<OutputType>exe</OutputType>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<DebugType>full</DebugType>
Expand Down Expand Up @@ -44,8 +45,7 @@
<PackageReference Include="System.Memory" />
<PackageReference Include="System.Threading.Tasks.Dataflow" />
<PackageReference Include="Xunit.Combinatorial" />
<PackageReference Include="Xunit.SkippableFact" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion test/Nerdbank.GitVersioning.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation and Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

global using Xunit.Abstractions;
global using Xunit;
Loading