Skip to content

Commit dd68c20

Browse files
authored
revert: xunit v3 migration (#26)
Revert back the xunit v3 migration, as [Stryker.NET doesn't handle xUnit v3 properly](stryker-mutator/stryker-net#3117).
1 parent ba88e06 commit dd68c20

File tree

8 files changed

+47
-14
lines changed

8 files changed

+47
-14
lines changed

.nuke/build.schema.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"CodeAnalysisEnd",
3737
"CodeCoverage",
3838
"Compile",
39+
"DotNetFrameworkUnitTests",
3940
"DotNetUnitTests",
4041
"MutationComment",
4142
"MutationTestExecution",

Directory.Packages.props

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
<ItemGroup>
2424
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0"/>
2525
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0"/>
26-
<PackageVersion Include="xunit.v3" Version="1.1.0"/>
26+
<PackageVersion Include="NUnit" Version="4.3.2"/>
27+
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0"/>
28+
<PackageVersion Include="NUnit.Analyzers" Version="4.6.0"/>
29+
<PackageVersion Include="xunit" Version="2.9.3"/>
2730
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2"/>
2831
<PackageVersion Include="coverlet.collector" Version="6.0.4"/>
2932
<PackageVersion Include="PublicApiGenerator" Version="11.4.2"/>

Pipeline/Build.UnitTest.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
using System.Linq;
22
using Nuke.Common;
3+
using Nuke.Common.IO;
34
using Nuke.Common.ProjectModel;
45
using Nuke.Common.Tooling;
56
using Nuke.Common.Tools.DotNet;
7+
using Nuke.Common.Tools.Xunit;
8+
using static Nuke.Common.Tools.Xunit.XunitTasks;
69
using static Nuke.Common.Tools.DotNet.DotNetTasks;
710

811
// ReSharper disable AllUnderscoreLocalParameterName
@@ -12,22 +15,41 @@ namespace Build;
1215
partial class Build
1316
{
1417
Target UnitTests => _ => _
18+
.DependsOn(DotNetFrameworkUnitTests)
1519
.DependsOn(DotNetUnitTests);
1620

1721
Project[] UnitTestProjects =>
1822
[
1923
Solution.Tests.aweXpect_Json_Tests,
2024
];
2125

26+
Target DotNetFrameworkUnitTests => _ => _
27+
.Unlisted()
28+
.DependsOn(Compile)
29+
.OnlyWhenDynamic(() => EnvironmentInfo.IsWin)
30+
.Executes(() =>
31+
{
32+
string[] testAssemblies = UnitTestProjects
33+
.SelectMany(project =>
34+
project.Directory.GlobFiles(
35+
$"bin/{(Configuration == Configuration.Debug ? "Debug" : "Release")}/net48/*.Tests.dll"))
36+
.Select(p => p.ToString())
37+
.ToArray();
38+
39+
Assert.NotEmpty(testAssemblies.ToList());
40+
41+
Xunit2(s => s
42+
.SetFramework("net48")
43+
.AddTargetAssemblies(testAssemblies)
44+
);
45+
});
46+
2247
Target DotNetUnitTests => _ => _
2348
.Unlisted()
2449
.DependsOn(Compile)
2550
.Executes(() =>
2651
{
27-
string[] excludedFrameworks =
28-
EnvironmentInfo.IsWin
29-
? []
30-
: ["net48"];
52+
string[] excludedFrameworks = ["net48",];
3153
DotNetTest(s => s
3254
.SetConfiguration(Configuration)
3355
.SetProcessEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", "en-US")

Tests/Directory.Build.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
</PropertyGroup>
99

1010
<PropertyGroup>
11-
<OutputType>exe</OutputType>
1211
<LangVersion>latest</LangVersion>
1312
<ImplicitUsings>disable</ImplicitUsings>
1413
<Nullable>enable</Nullable>
@@ -19,7 +18,7 @@
1918
</PropertyGroup>
2019

2120
<ItemGroup>
22-
<PackageReference Include="xunit.v3"/>
21+
<PackageReference Include="xunit"/>
2322
<PackageReference Include="xunit.runner.visualstudio">
2423
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2524
<PrivateAssets>all</PrivateAssets>

Tests/aweXpect.Json.Api.Tests/ApiAcceptance.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ public sealed class ApiAcceptance
55
/// <summary>
66
/// Execute this test to update the expected public API to the current API surface.
77
/// </summary>
8-
[Fact(Explicit = true)]
8+
[TestCase]
9+
[Explicit]
910
public async Task AcceptApiChanges()
1011
{
1112
string[] assemblyNames =

Tests/aweXpect.Json.Api.Tests/ApiApprovalTests.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
namespace aweXpect.Api.Tests;
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
4+
namespace aweXpect.Api.Tests;
25

36
/// <summary>
47
/// Whenever a test fails, this means that the public API surface changed.
@@ -7,8 +10,7 @@
710
/// </summary>
811
public sealed class ApiApprovalTests
912
{
10-
[Theory]
11-
[MemberData(nameof(TargetFrameworksTheoryData))]
13+
[TestCaseSource(nameof(TargetFrameworksTheoryData))]
1214
public async Task VerifyPublicApiForAweXpectJson(string framework)
1315
{
1416
const string assemblyName = "aweXpect.Json";
@@ -19,9 +21,9 @@ public async Task VerifyPublicApiForAweXpectJson(string framework)
1921
await That(publicApi).IsEqualTo(expectedApi);
2022
}
2123

22-
public static TheoryData<string> TargetFrameworksTheoryData()
24+
private static List<string> TargetFrameworksTheoryData()
2325
{
24-
TheoryData<string> theoryData = new();
26+
List<string> theoryData = new();
2527
foreach (string targetFramework in Helper.GetTargetFrameworks())
2628
{
2729
theoryData.Add(targetFramework);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
global using System;
22
global using System.Threading.Tasks;
3-
global using Xunit;
3+
global using NUnit.Framework;
44
global using aweXpect;
55
global using static aweXpect.Expect;

Tests/aweXpect.Json.Api.Tests/aweXpect.Json.Api.Tests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
</ItemGroup>
1010

1111
<ItemGroup>
12+
<PackageReference Remove="xunit"/>
13+
<PackageReference Remove="xunit.runner.visualstudio"/>
14+
<PackageReference Include="NUnit"/>
15+
<PackageReference Include="NUnit.Analyzers"/>
16+
<PackageReference Include="NUnit3TestAdapter"/>
1217
<PackageReference Include="PublicApiGenerator"/>
1318
</ItemGroup>
1419

0 commit comments

Comments
 (0)