You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ActivityWrapper (Microsoft.Testing.Extensions.OpenTelemetry) wraps a System.Diagnostics.Activity to implement IPlatformActivity. Several of its branches had no direct or indirect coverage in OpenTelemetryPlatformServiceTests.cs:
SetTag (only ever exercised implicitly via StartActivity(tags:), never called directly, and its chaining return value was unchecked)
RecordException's additionalTags merge parameter
TraceId/SpanId returning null for non-W3C (ActivityIdFormat.Hierarchical) activities
IsRecording returning false (only ever observed as true, via this test class's own listener which always samples AllDataAndRecorded)
The non-ambient Dispose() branch that saves/restores Activity.Current around activity.Dispose()
Approach
Added 5 tests to the existing OpenTelemetryPlatformServiceTests.cs (keeping the file's existing pattern of exercising ActivityWrapper through the real OpenTelemetryPlatformService plus a live ActivityListener, rather than mocking):
IsRecording_WhenNoListenerSamplesTheActivityForData_IsFalse — required a dedicated ActivitySource/ActivityListener pair sampling PropagationData (not AllDataAndRecorded), since the test class's shared listener always requests full data.
A small WrapNonAmbient(Activity) helper constructs ActivityWrapper directly (accessible via the project's existing InternalsVisibleTo) for the two tests that need to control activity state that OpenTelemetryPlatformService's public surface doesn't expose directly (a non-W3C-format activity, and a not-recorded activity).
Coverage impact
Before
After
Microsoft.Testing.Extensions.UnitTests (net8.0) total tests
1940
1945
Failed
0
0
Skipped (pre-existing)
51
51
Trade-offs
Minimal — all 5 new tests are small, focused, and follow the file's existing conventions (real Activity/ActivityListener instances rather than mocks, matching the class's documented approach).
Full Microsoft.Testing.Extensions.UnitTests net8.0 suite: 1945 total, 0 failed, 51 skipped (pre-existing, no regressions).
dotnet format whitespace TestFx.slnx --verify-no-changes --include <file>: clean (only the expected harmless F#-project warning unrelated to this change).
Note
This was originally intended as a pull request, but the git push operation failed.
Original error: The process '/usr/bin/git' failed with exit code 128
🤖 Automated content by GitHub Copilot. Generated by the Test Improver workflow. · copilot · auto · 245.1 AIC · ⌖ 23.5 AIC · ⊞ 17K · [◷]( · ◷) Comment /test-assist to run again
Add this agentic workflow to your repo
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/test-improver.md@main
Goal
ActivityWrapper(Microsoft.Testing.Extensions.OpenTelemetry) wraps aSystem.Diagnostics.Activityto implementIPlatformActivity. Several of its branches had no direct or indirect coverage inOpenTelemetryPlatformServiceTests.cs:SetTag(only ever exercised implicitly viaStartActivity(tags:), never called directly, and its chaining return value was unchecked)RecordException'sadditionalTagsmerge parameterTraceId/SpanIdreturningnullfor non-W3C (ActivityIdFormat.Hierarchical) activitiesIsRecordingreturningfalse(only ever observed astrue, via this test class's own listener which always samplesAllDataAndRecorded)Dispose()branch that saves/restoresActivity.Currentaroundactivity.Dispose()Approach
Added 5 tests to the existing
OpenTelemetryPlatformServiceTests.cs(keeping the file's existing pattern of exercisingActivityWrapperthrough the realOpenTelemetryPlatformServiceplus a liveActivityListener, rather than mocking):SetTag_SetsTheTagAndReturnsTheSameActivityForChainingRecordException_WithAdditionalTags_MergesThemOntoTheExceptionEventTraceIdAndSpanId_WhenActivityIsNotW3CFormat_AreNullIsRecording_WhenNoListenerSamplesTheActivityForData_IsFalse— required a dedicatedActivitySource/ActivityListenerpair samplingPropagationData(notAllDataAndRecorded), since the test class's shared listener always requests full data.Dispose_ForANonAmbientActivity_RestoresThePreviousAmbientActivityA small
WrapNonAmbient(Activity)helper constructsActivityWrapperdirectly (accessible via the project's existingInternalsVisibleTo) for the two tests that need to control activity state thatOpenTelemetryPlatformService's public surface doesn't expose directly (a non-W3C-format activity, and a not-recorded activity).Coverage impact
Microsoft.Testing.Extensions.UnitTests(net8.0) total testsTrade-offs
Minimal — all 5 new tests are small, focused, and follow the file's existing conventions (real
Activity/ActivityListenerinstances rather than mocks, matching the class's documented approach).Reproducibility
Test Status
Microsoft.Testing.Extensions.UnitTestsnet8.0 suite: 1945 total, 0 failed, 51 skipped (pre-existing, no regressions).dotnet format whitespace TestFx.slnx --verify-no-changes --include <file>: clean (only the expected harmless F#-project warning unrelated to this change).Note
This was originally intended as a pull request, but the git push operation failed.
Original error: The process '/usr/bin/git' failed with exit code 128
Workflow Run: View run details and download bundle artifact
The bundle file is available in the
agentartifact in the workflow run linked above.Create the pull request manually
Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
github.comsouthcentralus0.in.applicationinsights.azure.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run