Skip to content

Add report generator lifecycle tests - #10860

Merged
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/report-generator-lifecycle-tests
Aug 31, 2026
Merged

Add report generator lifecycle tests#10860
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/report-generator-lifecycle-tests

Conversation

@Evangelink

Copy link
Copy Markdown
Member

ReportGeneratorBase owns the session lifecycle shared by every report-generator extension, but that orchestration had no direct unit coverage. This adds focused coverage through CtrfReportGenerator, the smallest concrete implementation, without changing production code.

The tests verify:

  • enablement from the --report-ctrf option
  • invalid finishing-before-starting lifecycle ordering
  • passed and failed test result consumption while ignoring unrelated messages
  • report artifact publication with the active session UID
  • no output-device writes on the warning-free path

The test harness uses the real internal service provider with mocked platform dependencies. The unreachable-state assertion compares exception full names because the exception polyfill has separate type identities across target assemblies.

Tests: Microsoft.Testing.Extensions.UnitTests (1,495 passed, 7 skipped) and the focused lifecycle suite (5 passed).

Fixes #10850

Cover ReportGeneratorBase session enablement, ordering, message consumption, artifact publication, and output behavior through CtrfReportGenerator.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c7572463-f383-4eeb-82b4-15b66d4c02f8
Copilot AI balanced review requested due to automatic review settings August 29, 2026 08:13
@Evangelink Amaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Aug 29, 2026
@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) August 29, 2026 08:17
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Expert test review — PR #10860

Reviewed the 5 new test methods in CtrfReportGeneratorLifecycleTests.cs (the only test file changed in this PR). All five are well-constructed: clear Arrange-Act-Assert structure, meaningful value/state assertions (not just null checks), correct exception-type assertions with a documented cross-assembly caveat, and correct mock verification (Times.Never) for the no-warning path. No high-confidence actionable findings — nothing warrants an inline suggestion.

GradeTestMutationNotesHow to improve
A (90–100) new CtrfReportGeneratorLifecycleTests.
FullLifecycle_
ConsumesTestNodesAndPublishesArtifactAsync
4/4 killed Parses the emitted JSON and asserts exact test/passed/failed counts, plus session UID and file extension.
A (90–100) new CtrfReportGeneratorLifecycleTests.
IsEnabledAsync_
ReturnsFalse_
WhenOptionIsNotSetAsync
1/1 killed Directly asserts the negative branch of the option-set contract.
A (90–100) new CtrfReportGeneratorLifecycleTests.
IsEnabledAsync_
ReturnsTrue_
WhenOptionIsSetAsync
1/1 killed Directly asserts the positive branch; paired with the false-case test for full boolean coverage.
A (90–100) new CtrfReportGeneratorLifecycleTests.
OnTestSessionFinishingAsync_
WithoutPriorStart_
ThrowsUnreachableExceptionAsync
1/1 killed Exception test with a well-reasoned type-name comparison to avoid cross-assembly type-identity pitfalls on non-NETCOREAPP TFMs.
A (90–100) new CtrfReportGeneratorLifecycleTests.
OnTestSessionFinishingAsync_
WithoutWarning_
PublishesArtifactWithoutOutputAsync
1/1 killed Correctly verifies the output device is never invoked when there is no warning, using a meaningful mock verification.

This advisory comment was generated automatically. Grades are heuristic and informational — they do not block merging. Suggestions on the Files changed tab can be applied with one click. Re-run with /review-tests.

🤖 Automated content by GitHub Copilot. Generated by the Test Reviewer on PR (on open / sync) workflow. · auto · 75.4 AIC · ⌖ 1.16 AIC · ⊞ 16.9K · [◷]( · )

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

Review Summary

New unit tests for CtrfReportGenerator lifecycle — clean, well-structured test file that covers enable/disable, the unreachable-exception guard, full lifecycle with artifact publishing and JSON verification, and the no-warning path.

# Dimension Verdict
1 Algorithmic Correctness ✅ Clean
2 Error Handling ✅ Clean — UnreachableException assertion uses full-name comparison with a clear comment explaining the cross-assembly polyfill issue
3 Concurrency & Thread Safety N/A
4 Performance & Allocations ✅ Clean
5 API Design & Public Surface N/A — test-only code, no public API
6 Binary & Wire Compatibility N/A
7 Cross-TFM Correctness ✅ Clean — #if NETCOREAPP guard on DisposeAsync
8 Naming & Conventions ✅ Clean — follows Method_Condition_ExpectedAsync naming
9 Assertions & Test Quality ✅ Clean — uses MSTest assertions per BannedSymbols.txt; good use of Assert.HasCount, Assert.EndsWith, JSON structural assertions
10 Resource Management ⚠️ Minor — MemoryFileStream.Dispose() is a no-op; see inline comment
11 Localization N/A
12 Security ✅ Clean
13 Documentation ✅ Clean — the polyfill comment on the UnreachableException test is helpful
14 Null Safety ✅ Clean — null! for unused IDataProducer parameters is acceptable
15 Code Duplication ⚠️ Minor — MemoryFileStream and TestSessionContextStub are duplicated across multiple test files; see inline comment
16 Backward Compatibility N/A
17 Configuration ✅ Clean
18 init Accessor Ban N/A — no public API
19 PublicAPI.Unshipped.txt N/A
20 StyleCop / EditorConfig ✅ Clean
21 CLI Option Changes N/A
22 Scope Discipline ✅ Clean — single-concern PR adding tests for one component

Overall: Good test coverage addition. One minor inline comment about MemoryFileStream disposal consistency and potential deduplication — no blockers.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

Review tier: Balanced
Findings: None

What changed in this PR

Adds direct unit coverage for shared report-generator lifecycle orchestration through CtrfReportGenerator.

Changes:

  • Tests option-based enablement and invalid lifecycle ordering.
  • Verifies result consumption, artifact publication, session UID, and warning-free output behavior.
File Description
test/​UnitTests/​Microsoft.Testing.Extensions.UnitTests/​CtrfReportGeneratorLifecycleTests.cs Adds five focused lifecycle tests and supporting test doubles.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Delegate synchronous and asynchronous disposal to the inner memory stream for consistency with the existing report-engine test helper.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c7572463-f383-4eeb-82b4-15b66d4c02f8
Copilot AI review requested due to automatic review settings August 29, 2026 08:26
@github-actions

Copy link
Copy Markdown
Contributor

🧵 Parallel-safety audit — PR #10860

Parallelization — audited assembly:

Test assembly Scope Workers Analyzer coverage
Microsoft.Testing.Extensions.UnitTests MethodLevel ([assembly: Parallelize(Scope = ExecutionScope.MethodLevel, Workers = 0)] in Program.cs) CPU count coverable once the parallel-safety analyzers ship (attribute-based opt-in)

Nothing audited here touches process-global state, shared filesystem paths, or [ResourceLock] / [DoNotParallelize] declarations. Nothing to flag for parallel-safety.

The new file CtrfReportGeneratorLifecycleTests.cs adds 5 [TestMethod]s plus a CreateGenerator helper. Reviewed for category A/B/C/D hazards:

  • All mocks (Mock<IFileSystem>, Mock<IEnvironment>, etc.) and the ServiceProvider are created fresh per-test inside CreateGenerator — no shared/static mutable state across tests.
  • File I/O is fully virtualized: IFileSystem.NewFileStream returns an in-memory MemoryFileStream (wraps a private MemoryStream), so no real filesystem paths are touched — no shared-path collision is possible.
  • No Environment.*, Directory.SetCurrentDirectory, Console.Set*, or culture mutation anywhere in the file.
  • No [ResourceLock] / [DoNotParallelize] added, removed, or needed — the tests are naturally isolated per-instance state, so MethodLevel parallelism is safe for this class.

No findings to report.

Advisory only — heuristic, non-blocking. Re-run with /parallel-audit. This audit answers "is it parallel-safe?"; for testability, smells, or flakiness see the detect-static-dependencies / test-smell-detection / test-anti-patterns analyses.

🤖 Automated content by GitHub Copilot. Generated by the Parallel-safety audit on PR (on open / sync) workflow. · auto · 37.1 AIC · ⌖ 2.07 AIC · ⊞ 24.8K · [◷]( · )

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

Review tier: Balanced
Findings: None

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Expert test review — PR #10860

Reviewed the 5 new test methods in CtrfReportGeneratorLifecycleTests.cs (added alongside the CTRF report generator lifecycle wiring in ReportGeneratorBase/CtrfReportGenerator).

GradeTestMutationNotesHow to improve
A (90–100) new CtrfReportGeneratorLifecycleTests.
FullLifecycle_
ConsumesTestNodesAndPublishesArtifactAsync
4/4 killed Exercises the full pipeline and asserts summary counts and JSON content, correctly ignoring non-TestNodeUpdateMessage data.
A (90–100) new CtrfReportGeneratorLifecycleTests.
IsEnabledAsync_
ReturnsFalse_
WhenOptionIsNotSetAsync
1/1 killed Complements the true-case test; correctly verifies option-gated enablement.
A (90–100) new CtrfReportGeneratorLifecycleTests.
IsEnabledAsync_
ReturnsTrue_
WhenOptionIsSetAsync
1/1 killed Verifies the option-set path is enabled; behavior is fully captured by the true/false pair.
A (90–100) new CtrfReportGeneratorLifecycleTests.
OnTestSessionFinishingAsync_
WithoutPriorStart_
ThrowsUnreachableExceptionAsync
1/1 killed Correctly exercises the missing-_testStartTime guard; type-name comparison is justified by cross-assembly polyfill identity (documented in-code).
A (90–100) new CtrfReportGeneratorLifecycleTests.
OnTestSessionFinishingAsync_
WithoutWarning_
PublishesArtifactWithoutOutputAsync
2/2 killed Correctly verifies no output device call plus artifact publication when no warning is produced.

No new high-confidence issues found. One inline finding (the duplicated MemoryFileStream test helper with an inconsistent silent no-op Dispose()) was already raised and resolved earlier in the PR's review thread; no further action needed there.

This advisory comment was generated automatically. Grades are heuristic and informational — they do not block merging. Re-run with /review-tests.

🤖 Automated content by GitHub Copilot. Generated by the Test Reviewer on PR (on open / sync) workflow. · auto · 68.1 AIC · ⌖ 1.13 AIC · ⊞ 16.9K · [◷]( · )

@Evangelink
Amaury Levé (Evangelink) merged commit be6b395 into main Aug 31, 2026
44 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/report-generator-lifecycle-tests branch August 31, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[test-improver] Add unit tests for ReportGeneratorBase session lifecycle

3 participants