Skip to content

Commit f6edbe0

Browse files
committed
Update dependencies and improve test ordering logic #298
Bump Microsoft.Extensions.* and Microsoft.NET.Test.Sdk package versions to latest patch releases in both main and example projects. Update Azure Pipelines to use .NET SDK 9.0.301 and increment revision. Improve null safety and type resolution in TestPriorityOrderer, and update example tests to use cancellation tokens with Task.Delay.
1 parent 0f1aa4f commit f6edbe0

File tree

6 files changed

+26
-24
lines changed

6 files changed

+26
-24
lines changed

azure-pipeline-PR.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ steps:
1717
displayName: 'Use .NET 9.0 sdk'
1818
inputs:
1919
packageType: sdk
20-
version: 9.0.300
20+
version: 9.0.301
2121
installationPath: $(Agent.ToolsDirectory)/dotnet
2222
- script: echo Started restoring the source code
2323
- task: DotNetCoreCLI@2

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
variables:
22
Major: 9
33
Minor: 0
4-
Revision: 5
4+
Revision: 6
55
BuildConfiguration: Release
66

77
name: $(Major).$(Minor).$(Revision)
@@ -25,7 +25,7 @@ steps:
2525
displayName: 'Use .NET 9.0 sdk'
2626
inputs:
2727
packageType: sdk
28-
version: 9.0.300
28+
version: 9.0.301
2929
installationPath: $(Agent.ToolsDirectory)/dotnet
3030
- script: echo Started restoring the source code
3131
- task: DotNetCoreCLI@2

examples/Xunit.Microsoft.DependencyInjection.ExampleTests/UnitTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ public void Test2()
1616
[Fact, TestOrder(3)]
1717
public async Task Test3()
1818
{
19-
await Task.Delay(3000);
19+
await Task.Delay(3000, TestContext.Current.CancellationToken);
2020
Assert.Equal(1, 1);
2121
}
2222

2323
[Fact, TestOrder(4)]
2424
public async Task Test4()
2525
{
26-
await Task.Delay(5000);
26+
await Task.Delay(5000, TestContext.Current.CancellationToken);
2727
Assert.True(1 > 0);
2828
}
2929
}

examples/Xunit.Microsoft.DependencyInjection.ExampleTests/Xunit.Microsoft.DependencyInjection.ExampleTests.csproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.5" />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
14+
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.6" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
1616
<PackageReference Include="xunit.v3" Version="2.0.3" />
1717
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.1">
1818
<PrivateAssets>all</PrivateAssets>
@@ -22,13 +22,13 @@
2222
<PrivateAssets>all</PrivateAssets>
2323
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2424
</PackageReference>
25-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.5" />
26-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.5" />
27-
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.5" />
28-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.5" />
29-
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.5" />
30-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.5" />
31-
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.5" />
25+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.6" />
26+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.6" />
27+
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.6" />
28+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.6" />
29+
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.6" />
30+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.6" />
31+
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.6" />
3232
</ItemGroup>
3333
<ItemGroup>
3434
<None Remove="appsettings.json" />

src/TestsOrder/TestPriorityOrderer.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ public IReadOnlyCollection<TTestCase> OrderTestCases<TTestCase>(IReadOnlyCollect
1313
foreach (var testCase in testCases)
1414
{
1515
var priority = 0;
16-
1716
var testMethod = testCase.TestMethod;
18-
var type = Type.GetType(testMethod.TestClass.TestClassNamespace);
19-
var method = type?.GetMethod(testMethod.MethodName);
17+
var type = Type.GetType(testMethod?.TestClass.TestClassNamespace ?? string.Empty) ?? AppDomain.CurrentDomain
18+
.GetAssemblies()
19+
.Select(a => a.GetType(testMethod?.TestClass?.TestClassName ?? string.Empty))
20+
.FirstOrDefault(t => t != null);
21+
var method = type?.GetMethod(testMethod?.MethodName ?? string.Empty);
2022
var attributes = method?.GetCustomAttributes(typeof(TestOrderAttribute));
21-
foreach (var attr in attributes)
23+
foreach (var attr in attributes!)
2224
{
2325
if (attr is TestOrderAttribute orderAttr)
2426
{
@@ -32,7 +34,7 @@ public IReadOnlyCollection<TTestCase> OrderTestCases<TTestCase>(IReadOnlyCollect
3234
var testCaseCollection = new List<TTestCase>();
3335
foreach (var list in sortedMethods.Keys.Select(priority => sortedMethods[priority]))
3436
{
35-
list.Sort((x, y) => StringComparer.OrdinalIgnoreCase.Compare(x.TestMethod.MethodName, y.TestMethod.MethodName));
37+
list.Sort((x, y) => StringComparer.OrdinalIgnoreCase.Compare(x.TestMethod?.MethodName, y.TestMethod?.MethodName));
3638
foreach (var testCase in list)
3739
{
3840
testCaseCollection.Add(testCase);

src/Xunit.Microsoft.DependencyInjection.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
<PackageReadmeFile>README.md</PackageReadmeFile>
88
</PropertyGroup>
99
<ItemGroup>
10-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.5" />
11-
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.5" />
12-
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.5" />
13-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.5" />
10+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.6" />
11+
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.6" />
12+
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.6" />
13+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.6" />
1414
<PackageReference Include="xunit.v3.extensibility.core" Version="2.0.3" />
15-
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.5" />
15+
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.6" />
1616
</ItemGroup>
1717
<ItemGroup>
1818
<None Include="..\README.md" Pack="true" PackagePath="\" />

0 commit comments

Comments
 (0)