Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0246b46
Updating xunit package version and package references to xunit.v3
WhitWaldo Mar 5, 2026
aede978
Updated to pass test context cancellation token into all async methods
WhitWaldo Mar 12, 2026
2632862
Merge branch 'master' into xunit-migration
WhitWaldo Mar 12, 2026
1f40266
Updated xunit to v3 in example project
WhitWaldo Mar 13, 2026
ec83958
Migrating tests to xunit v3
WhitWaldo Mar 13, 2026
ca65218
Updated all unit tests with an async method that accepts a cancellati…
WhitWaldo Mar 13, 2026
ead8811
Avoiding apphost generation in CICD for test projects to resolve error
WhitWaldo Mar 13, 2026
379c250
Disabling apphost generation for test projects
WhitWaldo Mar 13, 2026
9f20ad0
xUnit requires apphost, so can't be disabling it
WhitWaldo Mar 13, 2026
eb4adfc
Explicitly setting all test projects to produce exe outputs for xunit 3
WhitWaldo Mar 13, 2026
d1c26f7
Fixed syntax tree mismatch
WhitWaldo Mar 13, 2026
b64ffe5
Added missing cancellation tokens for xunit v3
WhitWaldo Mar 13, 2026
29842d0
Removed unused using + using constant
WhitWaldo Mar 13, 2026
8901ecf
Overhauled integration tests (old) for xunit v3 as well
WhitWaldo Mar 13, 2026
58d0ea5
Added xunit cancellation token to workflow integration tests
WhitWaldo Mar 13, 2026
8f32f82
Updated to use xunit cancellation token
WhitWaldo Mar 13, 2026
6d2e4d3
Added library output type notation to override exe unit test outputs
WhitWaldo Mar 13, 2026
9a6d3f2
Updated to use the cancellation tokens and modern await using statements
WhitWaldo Mar 13, 2026
c84c6f4
Fixed build issues
WhitWaldo Mar 13, 2026
a6766fa
Requiring cancellation token for xunit tests
WhitWaldo Mar 13, 2026
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
2 changes: 2 additions & 0 deletions .github/workflows/sdk_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ jobs:
--logger "trx;LogFilePrefix=${{ matrix.prefix }}" \
--logger "GitHubActions;report-warnings=false" \
--results-directory "${{ github.workspace }}/TestResults" \
/p:RuntimeIdentifier=linux-x64 \
/p:CollectCoverage=true \
/p:CoverletOutputFormat=opencover \
/p:GITHUB_ACTIONS=false
Expand Down Expand Up @@ -298,6 +299,7 @@ jobs:
--logger "trx;LogFilePrefix=${{ matrix.prefix }}" \
--logger "GitHubActions;report-warnings=false" \
--results-directory "${{ github.workspace }}/TestResults" \
/p:RuntimeIdentifier=linux-x64 \
/p:CollectCoverage=true \
/p:CoverletOutputFormat=opencover \
/p:GITHUB_ACTIONS=false
Expand Down
5 changes: 3 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.3" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.103" />
<PackageVersion Include="Microsoft.Testing.Platform" Version="2.1.0" />
<PackageVersion Include="MinVer" Version="7.0.0" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="protobuf-net.Grpc.AspNetCore" Version="1.2.2" />
Expand All @@ -53,8 +54,8 @@
<PackageVersion Include="System.Net.ServerSentEvents" Version="10.0.3" />
<PackageVersion Include="System.Text.Json" Version="10.0.3" />
<PackageVersion Include="Testcontainers" Version="4.9.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.extensibility.core" Version="2.9.3" />
<PackageVersion Include="xunit.v3" Version="3.2.2" />
<PackageVersion Include="xunit.v3.extensibility.core" Version="3.2.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit.extensibility.core" />
<PackageReference Include="xunit.v3.extensibility.core" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion test/Dapr.AI.Test/Dapr.AI.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Hosting"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection"/>
<PackageReference Include="xunit.extensibility.core"/>
<PackageReference Include="xunit.v3.extensibility.core"/>
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
<PackageReference Include="xunit"/>
<PackageReference Include="xunit.v3"/>
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async Task DoSomethingAsync()
""";

context.ExpectedDiagnostics.Clear();
await context.RunAsync();
await context.RunAsync(TestContext.Current.CancellationToken);
}

[Fact]
Expand Down Expand Up @@ -80,7 +80,7 @@ private static async Task TimerCallback(byte[] data)
""";

context.ExpectedDiagnostics.Clear();
await context.RunAsync();
await context.RunAsync(TestContext.Current.CancellationToken);
}

[Fact]
Expand Down Expand Up @@ -111,7 +111,7 @@ private static async Task TimerCallback(byte[] data)
""";

context.ExpectedDiagnostics.Clear();
await context.RunAsync();
await context.RunAsync(TestContext.Current.CancellationToken);
}

[Fact]
Expand All @@ -138,7 +138,7 @@ public async Task DoSomethingAsync()
context.ExpectedDiagnostics.Add(new DiagnosticResult(TimerCallbackMethodPresentAnalyzer.DaprTimerCallbackMethodRule)
.WithSpan(8, 45, 8, 60)
.WithArguments("TimerCallback", "TestActorTimerRegistrationTimerCallbackNotPresent"));
await context.RunAsync();
await context.RunAsync(TestContext.Current.CancellationToken);
}
}

Expand Down
10 changes: 5 additions & 5 deletions test/Dapr.Actors.AspNetCore.IntegrationTest/ActivationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ActivationTests
[Fact]
public async Task CanActivateActorWithDependencyInjection()
{
using var factory = new AppWebApplicationFactory();
await using var factory = new AppWebApplicationFactory();
var httpClient = factory.CreateClient(new Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactoryClientOptions { HandleCookies = false });

// Doing this twice verifies that the Actor stays active and retains state using DI.
Expand All @@ -47,8 +47,8 @@ public async Task CanActivateActorWithDependencyInjection()

private async Task<string> IncrementCounterAsync(HttpClient httpClient, string actorId)
{
var actorTypeName = nameof(DependencyInjectionActor);
var methodName = nameof(DependencyInjectionActor.IncrementAsync);
const string actorTypeName = nameof(DependencyInjectionActor);
const string methodName = nameof(DependencyInjectionActor.IncrementAsync);

var request = new HttpRequestMessage(HttpMethod.Put, $"http://localhost/actors/{actorTypeName}/{actorId}/method/{methodName}");
var response = await httpClient.SendAsync(request);
Expand All @@ -59,7 +59,7 @@ private async Task<string> IncrementCounterAsync(HttpClient httpClient, string a

private async Task DeactivateActor(HttpClient httpClient, string actorId)
{
var actorTypeName = nameof(DependencyInjectionActor);
const string actorTypeName = nameof(DependencyInjectionActor);

var request = new HttpRequestMessage(HttpMethod.Delete, $"http://localhost/actors/{actorTypeName}/{actorId}");
var response = await httpClient.SendAsync(request);
Expand All @@ -82,4 +82,4 @@ private async Task Assert2XXStatusAsync(HttpResponseMessage response)
var text = await response.Content.ReadAsStringAsync();
throw new XunitException($"The response failed with a {response.StatusCode} and body:" + Environment.NewLine + text);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Dapr.Actors.AspNetCore.IntegrationTest;

using Dapr.Actors.AspNetCore.IntegrationTest.App;
using App;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
Expand All @@ -36,4 +36,4 @@ protected override IHostBuilder CreateHostBuilder()
});
return builder;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
14 changes: 7 additions & 7 deletions test/Dapr.Actors.AspNetCore.IntegrationTest/HostingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public void MapActorsHandlers_WithoutAddActors_Throws()
[Fact]
public async Task MapActorsHandlers_IncludesHealthChecks()
{
using var factory = new AppWebApplicationFactory();
await using var factory = new AppWebApplicationFactory();

var httpClient = factory.CreateClient(new Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactoryClientOptions { HandleCookies = false });
var response = await httpClient.GetAsync("/healthz");
var response = await httpClient.GetAsync("/healthz", TestContext.Current.CancellationToken);
await Assert2XXStatusAsync(response);
}

Expand All @@ -68,7 +68,7 @@ public async Task ActorsHealthz_ShouldNotRequireAuthorization()
var server = host.GetTestServer();

var httpClient = server.CreateClient();
var response = await httpClient.GetAsync("/healthz");
var response = await httpClient.GetAsync("/healthz", TestContext.Current.CancellationToken);
await Assert2XXStatusAsync(response);
}

Expand All @@ -82,10 +82,10 @@ public async Task MapActorsHandlers_ActorHealthCheckDoesNotConflict()
var server = host.GetTestServer();

var httpClient = server.CreateClient();
var response = await httpClient.GetAsync("/healthz");
var response = await httpClient.GetAsync("/healthz", TestContext.Current.CancellationToken);
await Assert2XXStatusAsync(response);

var text = await response.Content.ReadAsStringAsync();
var text = await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken);
Assert.Equal("Ice Cold, Solid Gold!", text);
}

Expand All @@ -97,7 +97,7 @@ public async Task MapActorsHandlers_WorksWithFallbackRoute()
var server = host.GetTestServer();

var httpClient = server.CreateClient();
var response = await httpClient.GetAsync("/dapr/config");
var response = await httpClient.GetAsync("/dapr/config", TestContext.Current.CancellationToken);
await Assert2XXStatusAsync(response);
}

Expand Down Expand Up @@ -237,4 +237,4 @@ private async Task Assert2XXStatusAsync(HttpResponseMessage response)
var text = await response.Content.ReadAsStringAsync();
throw new XunitException($"The response failed with a {response.StatusCode} and body:" + Environment.NewLine + text);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.AspNetCore.TestHost" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public async Task MapActorsHandlers_MapDaprConfigEndpoint()
var server = host.GetTestServer();

var httpClient = server.CreateClient();
var response = await httpClient.GetAsync("/dapr/config");
var response = await httpClient.GetAsync("/dapr/config", TestContext.Current.CancellationToken);

var text = await response.Content.ReadAsStringAsync();
var text = await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken);
Assert.Equal(@"{""entities"":[""TestActor""],""reentrancy"":{""enabled"":false}}", text);
}

Expand Down Expand Up @@ -98,4 +98,4 @@ private class TestActor : Actor, ITestActor
{
public TestActor(ActorHost host) : base(host) { }
}
}
}
Loading
Loading