[Infra] xunit v3 preparation - #5381
Merged
Merged
Conversation
- Fix test flakiness identified under xunit v3's changed execution model for async. - Add new dedicated MSBuild property for test TFM for .NET Framework. - Avoid 4.6.2-specific conditions and instead make them ".NET Framework". - Add shim to allow using xunit.v3's `TestContext` class to pass `CancellationToken`s to methods under test now. - Cherry-pick some code analyser fixes from open-telemetry#3867. - Remove redundant comments.
2 of 4 tasks
Pull request dashboard statusMerged · refreshed 2026-09-23 11:12 UTC Status above doesn't look right?
|
martincostello
marked this pull request as ready for review
September 23, 2026 08:55
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Moderate findings remain in test correctness and cancellation handling.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (3)
What changed in this PR
Prepares the test infrastructure for xUnit v3 by improving cancellation handling, reducing async-test flakiness, and standardizing .NET Framework targeting.
Changes:
- Adds a shared
TestContextcancellation shim. - Introduces
NetFrameworkVersionForTestsand updates framework conditions. - Improves test synchronization, cleanup, assertions, and AWS listener management.
| File | Reviewed changes |
|---|---|
test/Shared/TestContext.cs |
Adds the xUnit test cancellation shim. |
test/Shared/EnabledOnDockerPlatformTheoryAttribute.cs |
Seals the Docker-platform theory attribute. |
test/Shared/EnabledOnDockerPlatformFactAttribute.cs |
Seals the Docker-platform fact attribute. |
test/OpenTelemetry.Sampler.AWS.Tests/TestRulesCache.cs |
Updates concurrent operations and assertions. |
test/OpenTelemetry.Sampler.AWS.Tests/TestRateLimiter.cs |
Adds cancellation to worker tasks. |
test/OpenTelemetry.Sampler.AWS.Tests/TestAWSXRaySamplerClient.cs |
Adds cancellation to client calls. |
test/OpenTelemetry.Sampler.AWS.Tests/TestAWSXRayRemoteSampler.cs |
Makes delays cancellation-aware. |
test/OpenTelemetry.Sampler.AWS.Tests/OpenTelemetry.Sampler.AWS.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Resources.ProcessRuntime.Tests/OpenTelemetry.Resources.ProcessRuntime.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Resources.Process.Tests/OpenTelemetry.Resources.Process.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Resources.OperatingSystem.Tests/OpenTelemetry.Resources.OperatingSystem.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Resources.Host.Tests/OpenTelemetry.Resources.Host.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Resources.Gcp.Tests/OpenTelemetry.Resources.Gcp.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Resources.Azure.Tests/OpenTelemetry.Resources.Azure.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Resources.AWS.Tests/OpenTelemetry.Resources.AWS.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.PersistentStorage.FileSystem.Tests/OpenTelemetry.PersistentStorage.FileSystem.Tests.csproj |
Updates .NET Framework conditions. |
test/OpenTelemetry.PersistentStorage.Abstractions.Tests/OpenTelemetry.PersistentStorage.Abstractions.Tests.csproj |
Updates .NET Framework conditions. |
test/OpenTelemetry.OpAmp.Client.Tests/WsTransportTest.cs |
Adds cancellation and race-resistant waits. |
test/OpenTelemetry.OpAmp.Client.Tests/Tools/OpAmpFakeWebSocketServer.cs |
Adds blocking request-header retrieval. |
test/OpenTelemetry.OpAmp.Client.Tests/PlainHttpTransportTests.cs |
Adds cancellation-aware timeout handling. moderate (1 vote): propagate test cancellation before asserting completion. |
test/OpenTelemetry.OpAmp.Client.Tests/OpenTelemetry.OpAmp.Client.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.OpAmp.Client.Tests/OpAmpPipeTests.cs |
Passes cancellation to pipe operations. |
test/OpenTelemetry.OpAmp.Client.Tests/OpAmpHttpPipeTests.cs |
Passes cancellation to flush operations. moderate (1 vote): distinguish xUnit cancellation from a real timeout before throwing. |
test/OpenTelemetry.OpAmp.Client.Tests/OpAmpClientTests.cs |
Adds cancellation to client lifecycle tests. moderate (1 vote): check cancellation after Task.WhenAny before asserting completion. |
test/OpenTelemetry.OpAmp.Client.Tests/Messages/EffectiveConfigFileTests.cs |
Passes cancellation to async parsing. |
test/OpenTelemetry.OpAmp.Client.Tests/FrameProcessorTests.cs |
Updates concurrent worker setup. moderate (1 vote): remove the duplicate subscribe loop or balance it with unsubscribe work. |
test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryPropagationTests.netfx.cs |
Stabilizes concurrent activity collection. |
test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryDispatchMessageInspectorTests.netfx.cs |
Adds verifier cancellation. |
test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryDispatchMessageInspectorForOneWayOperationsTests.netfx.cs |
Adds verifier cancellation. |
test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryBindingElementForTcpTests.netfx.cs |
Adds verifier and delay cancellation. |
test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryBindingElementForHttpTests.cs |
Adds verifier cancellation. |
test/OpenTelemetry.Instrumentation.Wcf.Tests/OpenTelemetry.Instrumentation.Wcf.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.SqlClient.Tests/OpenTelemetry.Instrumentation.SqlClient.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.ServiceFabricRemoting.Tests/OpenTelemetry.Instrumentation.ServiceFabricRemoting.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.Runtime.Tests/RuntimeMetricsTests.cs |
Adds cancellation to worker tasks. |
test/OpenTelemetry.Instrumentation.Runtime.Tests/OpenTelemetry.Instrumentation.Runtime.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.Remoting.Tests/OpenTelemetry.Instrumentation.Remoting.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.Quartz.Tests/QuartzDiagnosticListenerTests.cs |
Adds cancellation to scheduler operations. |
test/OpenTelemetry.Instrumentation.Process.Tests/ProcessMetricsTests.cs |
Adds cancellation to concurrent workers. |
test/OpenTelemetry.Instrumentation.Process.Tests/OpenTelemetry.Instrumentation.Process.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.Owin.Tests/OpenTelemetry.Instrumentation.Owin.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs |
Adds cancellation and assertion improvements. |
test/OpenTelemetry.Instrumentation.Kusto.Tests/OpenTelemetry.Instrumentation.Kusto.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.Kusto.FuzzTests/OpenTelemetry.Instrumentation.Kusto.FuzzTests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.Http.Tests/OpenTelemetry.Instrumentation.Http.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTests.netfx.cs |
Adds cancellation to HTTP operations. |
test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.cs |
Adds cancellation and assertion improvements. |
test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs |
Adds cancellation and assertion improvements. |
test/OpenTelemetry.Instrumentation.Hangfire.Tests/OpenTelemetry.Instrumentation.Hangfire.Tests.csproj |
Updates framework conditions. |
test/OpenTelemetry.Instrumentation.GrpcNetClient.Tests/OpenTelemetry.Instrumentation.GrpcNetClient.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.GrpcNetClient.Tests/GrpcTests.server.cs |
Adds cancellation to RPC calls. |
test/OpenTelemetry.Instrumentation.GrpcNetClient.Tests/GrpcTests.client.cs |
Adds cancellation to RPC calls. |
test/OpenTelemetry.Instrumentation.GrpcCore.Tests/OpenTelemetry.Instrumentation.GrpcCore.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.GrpcCore.Tests/GrpcCoreClientInterceptorTests.cs |
Adds cancellation to interceptor tests. moderate (1 vote): pass TestContext.Current.CancellationToken to the stream-write overload. |
test/OpenTelemetry.Instrumentation.EventCounters.Tests/EventCountersMetricsTests.cs |
Makes delays cancellation-aware. |
test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/EntityFrameworkDiagnosticListenerTests.cs |
Simplifies test data and assertions. |
test/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests/ElasticsearchClientTests.cs |
Adds cancellation and assertion improvements. |
test/OpenTelemetry.Instrumentation.ConfluentKafka.Tests/OpenTelemetry.Instrumentation.ConfluentKafka.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.ConfluentKafka.Tests/InstrumentedProducerTests.cs |
Adds cancellation to producer calls. |
test/OpenTelemetry.Instrumentation.Cassandra.Tests/OpenTelemetry.Instrumentation.Cassandra.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.Cassandra.Tests/CassandraInstrumentationTests.cs |
Disposes clusters and updates metric checks. moderate (3 votes): retain a sorted exact metric-set comparison instead of only Contains assertions. |
test/OpenTelemetry.Instrumentation.AWS.Tests/TestAWSClientMetricsInstrumentation.cs |
Adds cancellation and assertion improvements. |
test/OpenTelemetry.Instrumentation.AWS.Tests/TestAWSClientInstrumentation.cs |
Adds cancellation and registry cleanup. |
test/OpenTelemetry.Instrumentation.AWS.Tests/OpenTelemetry.Instrumentation.AWS.Tests.csproj |
Configures the dedicated test framework target. |
test/OpenTelemetry.Instrumentation.AWS.Tests/AWSClientInstrumentationOptionsTests.cs |
Adds collection synchronization metadata. moderate (2 votes): use a separate public [CollectionDefinition] type and keep [Collection] on the test class. |
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/RouteTests/RoutingTestFixture.cs |
Simplifies helper methods. |
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs |
Adds cancellation to HTTP and delay operations. |
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs |
Adds cancellation and assertion improvements. |
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/EndToEndTests.cs |
Adds request cancellation. |
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs |
Improves factory cleanup and synchronization. |
test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInMetricsListenerTests.cs |
Adds cancellation to worker tasks. |
test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs |
Adds cancellation to background tasks. |
test/OpenTelemetry.Extensions.Tests/Trace/RateLimitingSamplerTests.cs |
Makes delays cancellation-aware. |
test/OpenTelemetry.Extensions.Tests/OpenTelemetry.Extensions.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Extensions.FuzzTests/OpenTelemetry.Extensions.FuzzTests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetryEnrichmentServiceCollectionExtensionsTests.cs |
Adds cancellation and assertion improvements. |
test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetry.Extensions.Enrichment.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Extensions.Enrichment.Http.Tests/OpenTelemetry.Extensions.Enrichment.Http.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Extensions.Enrichment.Http.Tests/HttpClientTraceEnrichmentAcceptanceTests.cs |
Adds request cancellation. |
test/OpenTelemetry.Extensions.Enrichment.AspNetCore.Tests/EnrichmentTests.cs |
Simplifies wait helpers and assertions. |
test/OpenTelemetry.Extensions.Benchmarks/OpenTelemetry.Extensions.Benchmarks.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Extensions.AWS.Tests/OpenTelemetry.Extensions.AWS.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Extensions.AWS.Tests/AWSXRayIdGeneratorTests.cs |
Disposes test activities. |
test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj |
Removes a redundant framework comment. |
test/OpenTelemetry.Exporter.OneCollector.Benchmarks/OpenTelemetry.Exporter.OneCollector.Benchmarks.csproj |
Updates benchmark framework targeting. |
test/OpenTelemetry.Exporter.InfluxDB.Tests/OpenTelemetry.Exporter.InfluxDB.Tests.csproj |
Updates .NET Framework conditions. |
test/OpenTelemetry.Exporter.Geneva.Tests/MessagePackSerializerTests.cs |
Adds cancellation to deserialization. |
test/OpenTelemetry.Exporter.Geneva.Tests/GenevaTraceExporterTests.cs |
Adds cancellation to deserialization. |
test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs |
Adds cancellation and assertion improvements. |
test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterAFDCorrelationTests.cs |
Adds cancellation and assertion improvements. |
test/OpenTelemetry.DynamicControl.Tests/PolicyStoreConcurrencyTests.cs |
Adds cancellation to concurrent operations. |
test/OpenTelemetry.DynamicControl.Tests/PolicyCoordinatorTests.cs |
Adds cancellation to refresh operations. |
test/OpenTelemetry.DynamicControl.Tests/PolicyCoordinatorIntegrationTests.cs |
Adds cancellation to refresh operations. |
test/OpenTelemetry.DynamicControl.Tests/PolicyChangeSubscriptionTests.cs |
Adds cancellation to waits and delays. |
test/OpenTelemetry.DynamicControl.Tests/OpenTelemetry.DynamicControl.Tests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.DynamicControl.FuzzTests/OpenTelemetry.DynamicControl.FuzzTests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Contrib.Shared.Tests/SqlProcessorTestCases.cs |
Makes test-case construction explicit. |
test/OpenTelemetry.Contrib.Shared.Tests/OpenTelemetry.Contrib.Shared.Tests.csproj |
Updates framework conditions. |
test/OpenTelemetry.Contrib.Shared.FuzzTests/OpenTelemetry.Contrib.Shared.FuzzTests.csproj |
Uses the dedicated test TFM property. |
test/OpenTelemetry.Contrib.Shared.Benchmarks/OpenTelemetry.Contrib.Shared.Benchmarks.csproj |
Uses the dedicated test TFM property. |
src/OpenTelemetry.Resources.Host/HostDetector.cs |
Uses collection-expression syntax. |
src/OpenTelemetry.PersistentStorage.FileSystem/OpenTelemetry.PersistentStorage.FileSystem.csproj |
Updates .NET Framework conditions. |
src/OpenTelemetry.PersistentStorage.Abstractions/OpenTelemetry.PersistentStorage.Abstractions.csproj |
Updates .NET Framework conditions. |
src/OpenTelemetry.Extensions.AWS/AWSXRayIdGenerator.cs |
Manages global listener lifetime. nit (2 votes): document the listener-lifetime/runtime fix in the component changelog. |
src/OpenTelemetry.DynamicControl/OpenTelemetry.DynamicControl.csproj |
Updates .NET Framework conditions. |
build/Common.props |
Defines the dedicated test framework property. |
build/Common.nonprod.props |
Links the shared test-context shim into test projects. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Kielek
approved these changes
Sep 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Relates to open-telemetry/opentelemetry-dotnet#7740.
(Sorry for the size of the PR)
Changes
TestContextclass to passCancellationTokens to methods under test now.Merge requirement checklist
AppropriateCHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)