Skip to content

Commit 20abff5

Browse files
authored
Merge pull request #1147 from dotnet/rollbackToXunitv2
Rollback to xunit v2
2 parents 26a9056 + 081725a commit 20abff5

File tree

9 files changed

+32
-72
lines changed

9 files changed

+32
-72
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ NPM packages too.
4343

4444
## Testing
4545

46-
The Visual Studio 2019 Test Explorer will list and execute all tests.
46+
`dotnet test` will run all tests.
47+
48+
The Visual Studio 2022 Test Explorer will list and execute all tests.
49+
50+
A few tests will fail without a certain VC++ toolset installed.
4751

4852
## Releases
4953

Directory.Packages.props

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@
3838
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
3939
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="9.0.0" />
4040
<PackageVersion Include="Validation" Version="2.5.51" />
41-
<PackageVersion Include="Xunit.Combinatorial" Version="2.0.5-alpha" />
41+
<PackageVersion Include="Xunit.Combinatorial" Version="1.6.24" />
42+
<PackageVersion Include="Xunit.SkippableFact" Version="1.5.23" />
4243
</ItemGroup>
4344
<ItemGroup Label="Library.Template">
4445
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
4546
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />
46-
<PackageVersion Include="xunit.v3" Version="1.0.0" />
47+
<PackageVersion Include="xunit" Version="2.9.2" />
4748
</ItemGroup>
4849
<ItemGroup>
4950
<!-- Put repo-specific GlobalPackageReference items in this group. -->

test/Cake.GitVersioning.Tests/Cake.GitVersioning.Tests.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>net8.0</TargetFrameworks>
5-
<OutputType>Exe</OutputType>
65
<SignAssembly>false</SignAssembly>
76
<IsTestProject>true</IsTestProject>
87
<IsPackable>false</IsPackable>
@@ -19,7 +18,7 @@
1918
<PackageReference Include="Microsoft.NET.Test.Sdk" />
2019
<PackageReference Include="Nerdbank.GitVersioning.LKG" />
2120
<PackageReference Include="xunit.runner.visualstudio" />
22-
<PackageReference Include="xunit.v3" />
21+
<PackageReference Include="xunit" />
2322
</ItemGroup>
2423

2524
</Project>

test/Nerdbank.GitVersioning.Tests/AssemblyInfoTest.cs

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
public class AssemblyInfoTest : IClassFixture<MSBuildFixture> // The MSBuildFixture throws PlatformNotSupportedException when run on mono.
1515
{
16-
[Theory]
16+
[SkippableTheory(typeof(PlatformNotSupportedException))]
1717
[InlineData(false)]
1818
[InlineData(true)]
1919
[InlineData(null)]
@@ -49,15 +49,7 @@ public void FSharpGenerator(bool? thisAssemblyClass)
4949
info.EmitThisAssemblyClass = thisAssemblyClass.GetValueOrDefault();
5050
}
5151

52-
string built;
53-
try
54-
{
55-
built = info.BuildCode();
56-
}
57-
catch (PlatformNotSupportedException ex)
58-
{
59-
throw SkipException.ForSkip(ex.Message);
60-
}
52+
string built = info.BuildCode();
6153

6254
string expected = $@"//------------------------------------------------------------------------------
6355
// <auto-generated>
@@ -99,7 +91,7 @@ type internal ThisAssembly() =
9991
Assert.Equal(expected, built);
10092
}
10193

102-
[Theory]
94+
[SkippableTheory(typeof(PlatformNotSupportedException))]
10395
[InlineData(null, "MyRootNamespace")]
10496
[InlineData("", "MyRootNamespace")]
10597
[InlineData("MyCustomNamespace", null)]
@@ -117,15 +109,7 @@ public void FSharpGeneratorWithNamespace(string thisAssemblyNamespace, string ro
117109
ThisAssemblyNamespace = thisAssemblyNamespace,
118110
};
119111

120-
string built;
121-
try
122-
{
123-
built = info.BuildCode();
124-
}
125-
catch (PlatformNotSupportedException ex)
126-
{
127-
throw SkipException.ForSkip(ex.Message);
128-
}
112+
string built = info.BuildCode();
129113

130114
string expected = $@"//------------------------------------------------------------------------------
131115
// <auto-generated>
@@ -168,7 +152,7 @@ type internal ThisAssembly() =
168152
Assert.Equal(expected, built);
169153
}
170154

171-
[Theory]
155+
[SkippableTheory(typeof(PlatformNotSupportedException))]
172156
[InlineData(false)]
173157
[InlineData(true)]
174158
[InlineData(null)]
@@ -204,15 +188,7 @@ public void CSharpGenerator(bool? thisAssemblyClass)
204188
info.EmitThisAssemblyClass = thisAssemblyClass.GetValueOrDefault();
205189
}
206190

207-
string built;
208-
try
209-
{
210-
built = info.BuildCode();
211-
}
212-
catch (PlatformNotSupportedException ex)
213-
{
214-
throw SkipException.ForSkip(ex.Message);
215-
}
191+
string built = info.BuildCode();
216192

217193
string expected = $@"//------------------------------------------------------------------------------
218194
// <auto-generated>
@@ -252,7 +228,7 @@ internal static partial class ThisAssembly {{
252228
Assert.Equal(expected, built);
253229
}
254230

255-
[Theory]
231+
[SkippableTheory(typeof(PlatformNotSupportedException))]
256232
[InlineData(null, "MyRootNamespace")]
257233
[InlineData("", "MyRootNamespace")]
258234
[InlineData("MyCustomNamespace", null)]
@@ -270,15 +246,7 @@ public void CSharpGeneratorWithNamespace(string thisAssemblyNamespace, string ro
270246
ThisAssemblyNamespace = thisAssemblyNamespace,
271247
};
272248

273-
string built;
274-
try
275-
{
276-
built = info.BuildCode();
277-
}
278-
catch (PlatformNotSupportedException ex)
279-
{
280-
throw SkipException.ForSkip(ex.Message);
281-
}
249+
string built = info.BuildCode();
282250

283251
(string nsStart, string nsEnd) = !string.IsNullOrWhiteSpace(thisAssemblyNamespace)
284252
? ($"{Environment.NewLine}namespace {thisAssemblyNamespace} {{", $"{Environment.NewLine}}}")
@@ -318,7 +286,7 @@ internal static partial class ThisAssembly {{
318286
Assert.Equal(expected, built);
319287
}
320288

321-
[Theory]
289+
[SkippableTheory(typeof(PlatformNotSupportedException))]
322290
[InlineData(false)]
323291
[InlineData(true)]
324292
[InlineData(null)]
@@ -335,15 +303,7 @@ public void VisualBasicGenerator(bool? thisAssemblyClass)
335303
info.EmitThisAssemblyClass = thisAssemblyClass.GetValueOrDefault();
336304
}
337305

338-
string built;
339-
try
340-
{
341-
built = info.BuildCode();
342-
}
343-
catch (PlatformNotSupportedException ex)
344-
{
345-
throw SkipException.ForSkip(ex.Message);
346-
}
306+
string built = info.BuildCode();
347307

348308
string expected = $@"'------------------------------------------------------------------------------
349309
' <auto-generated>
@@ -382,7 +342,7 @@ End Class
382342
Assert.Equal(expected, built);
383343
}
384344

385-
[Theory]
345+
[SkippableTheory(typeof(PlatformNotSupportedException))]
386346
[InlineData(null, "MyRootNamespace")]
387347
[InlineData("", "MyRootNamespace")]
388348
[InlineData("MyCustomNamespace", null)]
@@ -400,15 +360,7 @@ public void VisualBasicGeneratorWithNamespace(string thisAssemblyNamespace, stri
400360
ThisAssemblyNamespace = thisAssemblyNamespace,
401361
};
402362

403-
string built;
404-
try
405-
{
406-
built = info.BuildCode();
407-
}
408-
catch (PlatformNotSupportedException ex)
409-
{
410-
throw SkipException.ForSkip(ex.Message);
411-
}
363+
string built = info.BuildCode();
412364

413365
(string nsStart, string nsEnd) = !string.IsNullOrWhiteSpace(thisAssemblyNamespace)
414366
? ($"{Environment.NewLine}Namespace {thisAssemblyNamespace}", $"{Environment.NewLine}End Namespace")

test/Nerdbank.GitVersioning.Tests/BuildIntegrationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ public async Task AssemblyInfo_HasKeyData(string keyFile, bool delaySigned)
176176
result.BuildResult.ProjectStateAfterBuild.GetPropertyValue("VersionSourceFile"))));
177177
this.Logger.WriteLine(versionCsContent);
178178

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

183183
var publicKeyField = (LiteralExpressionSyntax)fields.SingleOrDefault(f => f.Identifier.ValueText == "PublicKey")?.Initializer.Value;

test/Nerdbank.GitVersioning.Tests/GitContextTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ public void SelectCommitByPartialId(bool fromPack, bool oddLength)
9393
Assert.Equal(this.LibGit2Repository.Head.Tip.Sha, this.Context.GitCommitId);
9494
}
9595

96-
[Theory]
96+
[SkippableTheory]
9797
[InlineData(4)]
9898
[InlineData(7)]
9999
[InlineData(8)]
100100
[InlineData(11)]
101101
public void GetShortUniqueCommitId(int length)
102102
{
103-
Assert.SkipWhen(length < 7 && this.Context is Nerdbank.GitVersioning.LibGit2.LibGit2Context, "LibGit2Sharp never returns commit IDs with fewer than 7 characters.");
103+
Skip.If(length < 7 && this.Context is Nerdbank.GitVersioning.LibGit2.LibGit2Context, "LibGit2Sharp never returns commit IDs with fewer than 7 characters.");
104104
Assert.Equal(this.Context.GitCommitId.Substring(0, length), this.Context.GetShortUniqueCommitId(length));
105105
}
106106

test/Nerdbank.GitVersioning.Tests/LibGit2GitExtensionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ public void GetIdAsVersion_MigrationFromVersionTxtToJson()
467467
public void TestBiggerRepo()
468468
{
469469
string testBiggerRepoPath = @"D:\git\Nerdbank.GitVersioning";
470-
Assert.SkipWhen(!Directory.Exists(testBiggerRepoPath), $"{testBiggerRepoPath} does not exist.");
470+
Skip.If(!Directory.Exists(testBiggerRepoPath), $"{testBiggerRepoPath} does not exist.");
471471

472472
using var largeRepo = new Repository(testBiggerRepoPath);
473473
foreach (Commit commit in largeRepo.Head.Commits)

test/Nerdbank.GitVersioning.Tests/Nerdbank.GitVersioning.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<PropertyGroup>
33
<TargetFrameworks>net9.0</TargetFrameworks>
44
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(TargetFrameworks);net472</TargetFrameworks>
5-
<OutputType>Exe</OutputType>
65
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
76
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
87
<DebugType>full</DebugType>
@@ -45,7 +44,8 @@
4544
<PackageReference Include="System.Memory" />
4645
<PackageReference Include="System.Threading.Tasks.Dataflow" />
4746
<PackageReference Include="Xunit.Combinatorial" />
47+
<PackageReference Include="Xunit.SkippableFact" />
4848
<PackageReference Include="xunit.runner.visualstudio" />
49-
<PackageReference Include="xunit.v3" />
49+
<PackageReference Include="xunit" />
5050
</ItemGroup>
5151
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Copyright (c) .NET Foundation and Contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
global using Xunit.Abstractions;

0 commit comments

Comments
 (0)