Skip to content

Commit c4d99ff

Browse files
authored
Move to xunit v3 (#452)
1 parent aa977ef commit c4d99ff

File tree

7 files changed

+23
-25
lines changed

7 files changed

+23
-25
lines changed

src/Directory.Packages.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
<!-- Tests -->
2020
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
2121
<PackageVersion Include="System.Reflection.MetadataLoadContext" Version="10.0.3" />
22-
<PackageVersion Include="xunit" Version="2.9.3" />
22+
<PackageVersion Include="xunit.v3" Version="3.2.2" />
2323
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
24-
<PackageVersion Include="Xunit.SkippableFact" Version="1.5.61" />
2524
<!-- Misc -->
2625
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
2726
</ItemGroup>

src/Microsoft.Unity.Analyzers.Tests/ConsistencyTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using Microsoft.CodeAnalysis;
1313
using Microsoft.CodeAnalysis.Diagnostics;
1414
using Xunit;
15-
using Xunit.Abstractions;
1615

1716
namespace Microsoft.Unity.Analyzers.Tests;
1817

@@ -124,12 +123,12 @@ public async Task CheckHelpLinks()
124123
Assert.NotEmpty(d.HelpLinkUri);
125124
Assert.Contains(d.Id, d.HelpLinkUri);
126125

127-
var response = await client.GetAsync(d.HelpLinkUri);
126+
var response = await client.GetAsync(d.HelpLinkUri, TestContext.Current.CancellationToken);
128127
Assert.True(response.IsSuccessStatusCode);
129128
}
130129
}
131130

132-
[SkippableFact]
131+
[Fact]
133132
public void CheckCodeFixTestsHaveTriviaTests()
134133
{
135134
var assembly = typeof(ConsistencyTests).Assembly;
@@ -153,7 +152,7 @@ public void CheckCodeFixTestsHaveTriviaTests()
153152
missingTriviaTests.Add(testClass.Name);
154153
}
155154

156-
Skip.If(missingTriviaTests.Any(), $"The following CodeFix test classes ({(float)missingTriviaTests.Count / codeFixTestClasses.Length:0.00%}) are missing a Trivia test:\n\n{string.Join("\n", missingTriviaTests)}");
155+
Assert.SkipWhen(missingTriviaTests.Any(), $"The following CodeFix test classes ({(float)missingTriviaTests.Count / codeFixTestClasses.Length:0.00%}) are missing a Trivia test:\n\n{string.Join("\n", missingTriviaTests)}");
157156
}
158157

159158
private static bool IsBaseCodeFixVerifierTest(Type type)

src/Microsoft.Unity.Analyzers.Tests/GetLocalPositionAndRotationTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.Unity.Analyzers.Tests;
1111
public class GetLocalPositionAndRotationTests : BaseCodeFixVerifierTest<GetLocalPositionAndRotationAnalyzer, GetLocalPositionAndRotationCodeFix>
1212
{
1313
// For extensive testing, see GetPositionAndRotationTests
14-
[SkippableFact]
14+
[Fact]
1515
public async Task UseGetLocalPositionAndRotationMethod()
1616
{
1717
const string test = @"
@@ -31,7 +31,7 @@ void Update()
3131
var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName;
3232
var type = typeof(UnityEngine.Transform);
3333

34-
Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
34+
Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
3535

3636
var diagnostic = ExpectDiagnostic().WithLocation(9, 9);
3737

@@ -53,7 +53,7 @@ void Update()
5353
await VerifyCSharpFixAsync(test, fixedTest);
5454
}
5555

56-
[SkippableFact]
56+
[Fact]
5757
public async Task UseGetLocalPositionAndRotationMethodTransformAccess()
5858
{
5959
const string test = @"
@@ -73,7 +73,7 @@ void Method()
7373
var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName;
7474
var type = typeof(UnityEngine.Jobs.TransformAccess);
7575

76-
Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
76+
Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
7777

7878
var diagnostic = ExpectDiagnostic().WithLocation(9, 9);
7979

@@ -95,7 +95,7 @@ void Method()
9595
await VerifyCSharpFixAsync(test, fixedTest);
9696
}
9797

98-
[SkippableFact]
98+
[Fact]
9999
public async Task NoTypeMismatch()
100100
{
101101
const string test = @"
@@ -116,7 +116,7 @@ void Update()
116116
await VerifyCSharpDiagnosticAsync(test);
117117
}
118118

119-
[SkippableFact]
119+
[Fact]
120120
public async Task UseGetLocalPositionAndRotationMethodTrivia()
121121
{
122122
const string test = @"
@@ -139,7 +139,7 @@ void Update()
139139
var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName;
140140
var type = typeof(UnityEngine.Transform);
141141

142-
Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
142+
Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
143143

144144
var diagnostic = ExpectDiagnostic().WithLocation(10, 9);
145145

src/Microsoft.Unity.Analyzers.Tests/GetPositionAndRotationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void Update()
4949
await VerifyCSharpFixAsync(test, fixedTest);
5050
}
5151

52-
[SkippableFact]
52+
[Fact]
5353
public async Task UseGetPositionAndRotationMethodTransformAccess()
5454
{
5555
const string test = @"
@@ -72,7 +72,7 @@ void Method()
7272
var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName;
7373
var type = typeof(UnityEngine.Jobs.TransformAccess);
7474

75-
Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
75+
Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
7676

7777
var diagnostic = ExpectDiagnostic().WithLocation(12, 9);
7878

src/Microsoft.Unity.Analyzers.Tests/Microsoft.Unity.Analyzers.Tests.csproj

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

33
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
45
<TargetFramework>net10.0</TargetFramework>
56
<Nullable>enable</Nullable>
67
<NoWarn>NU1608;VSTHRD200</NoWarn>
@@ -12,9 +13,8 @@
1213
<PackageReference Include="Microsoft.NET.Test.Sdk" />
1314
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" />
1415
<PackageReference Include="System.Reflection.MetadataLoadContext" />
15-
<PackageReference Include="xunit" />
16+
<PackageReference Include="xunit.v3" />
1617
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all" />
17-
<PackageReference Include="Xunit.SkippableFact" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

src/Microsoft.Unity.Analyzers.Tests/SetLocalPositionAndRotationTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.Unity.Analyzers.Tests;
1111
public class SetLocalPositionAndRotationTests : BaseCodeFixVerifierTest<SetLocalPositionAndRotationAnalyzer, SetLocalPositionAndRotationCodeFix>
1212
{
1313
// For extensive testing, see SetPositionAndRotationTests.cs
14-
[SkippableFact]
14+
[Fact]
1515
public async Task UpdateLocalPositionAndRotationMethod()
1616
{
1717
const string test = @"
@@ -30,7 +30,7 @@ void Update()
3030
var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName;
3131
var type = typeof(UnityEngine.Transform);
3232

33-
Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
33+
Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
3434

3535
var diagnostic = ExpectDiagnostic().WithLocation(8, 9);
3636

@@ -51,7 +51,7 @@ void Update()
5151
await VerifyCSharpFixAsync(test, fixedTest);
5252
}
5353

54-
[SkippableFact]
54+
[Fact]
5555
public async Task UpdateLocalPositionAndRotationMethodTransformAccess()
5656
{
5757
const string test = @"
@@ -72,7 +72,7 @@ void Method()
7272
var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName;
7373
var type = typeof(UnityEngine.Jobs.TransformAccess);
7474

75-
Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
75+
Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
7676

7777
var diagnostic = ExpectDiagnostic().WithLocation(10, 9);
7878

@@ -95,7 +95,7 @@ void Method()
9595
await VerifyCSharpFixAsync(test, fixedTest);
9696
}
9797

98-
[SkippableFact]
98+
[Fact]
9999
public async Task UpdateLocalPositionAndRotationMethodTrivia()
100100
{
101101
const string test = @"
@@ -116,7 +116,7 @@ void Update()
116116
var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName;
117117
var type = typeof(UnityEngine.Transform);
118118

119-
Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
119+
Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
120120

121121
var diagnostic = ExpectDiagnostic().WithLocation(9, 9);
122122

src/Microsoft.Unity.Analyzers.Tests/SetPositionAndRotationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void Update()
4545
await VerifyCSharpFixAsync(test, fixedTest);
4646
}
4747

48-
[SkippableFact]
48+
[Fact]
4949
public async Task UpdatePositionAndRotationMethodTransformAccess()
5050
{
5151
const string test = @"
@@ -66,7 +66,7 @@ void Method()
6666
var method = GetCSharpDiagnosticAnalyzer().ExpressionContext.PositionAndRotationMethodName;
6767
var type = typeof(UnityEngine.Jobs.TransformAccess);
6868

69-
Skip.IfNot(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
69+
Assert.SkipUnless(MethodExists("UnityEngine", type.FullName!, method), $"This Unity version does not support {type}.{method}");
7070

7171
var diagnostic = ExpectDiagnostic().WithLocation(10, 9);
7272

0 commit comments

Comments
 (0)