Skip to content

[tests] Improve NUnit runner reporting and dry-run auditing#11162

Open
simonrozsival wants to merge 3 commits intomainfrom
dev/simonrozsival/nunit-summary-counts
Open

[tests] Improve NUnit runner reporting and dry-run auditing#11162
simonrozsival wants to merge 3 commits intomainfrom
dev/simonrozsival/nunit-summary-counts

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

@simonrozsival simonrozsival commented Apr 20, 2026

Summary

Improve the Android NUnit harness so trimmable and test-lane investigations can audit discovery and exclusions reliably.

Changes

  • fix final Passed/Failed/Skipped summary counts to match NUnit aggregate results
  • add a discovery-only dry-run mode
  • add noexclusions=true to bypass built-in exclusions for auditing
  • surface excluded tests as ignored results with explicit reasons
  • overwrite logcat output per run so stale logs do not masquerade as current crashes

Why

These generic test-runner improvements were useful while working on #11091. I had problems identifying which tests were discovered, but did not run, as passed + skipped + failed < total.

Use NUnit's aggregate TestSuiteResult counts when reporting the final summary so skipped/ignored fixtures are included in the console output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 20, 2026 09:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the Android NUnit harness’ final console summary counts so they match NUnit’s aggregate result tree (and therefore the XML output), addressing undercounting when entire fixtures/suites are ignored.

Changes:

  • Update the runner to refresh Passed/Failed/Skipped/Inconclusive from TestSuiteResult aggregate counts after adding each assembly’s results.
  • Compute ExecutedTests from the aggregate counters to keep the reported totals consistent.

@simonrozsival simonrozsival added the copilot `copilot-cli` or other AIs were used to author this label Apr 20, 2026
Add discovery-only dry runs, a noexclusions switch, explicit skip reasons, and ignored-test visibility for the Android NUnit harness. Also overwrite stale logcat captures so crash diagnosis reflects the current run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival changed the title [tests] Fix NUnit summary counts for ignored tests [tests] Improve NUnit runner reporting and dry-run auditing Apr 20, 2026
simonrozsival added a commit that referenced this pull request Apr 20, 2026
Keep the trimmable typemap PR focused on the CoreCLRTrimmable lane and its targeted test-side plumbing. Move the generic NUnit runner and logcat auditing work to PR #11162, and drop the leftover Preserve-related noise.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
Copy link
Copy Markdown
Member

/review

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 20, 2026

Android PR Reviewer completed successfully!

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🤖 Review Summary — ✅ LGTM (with minor suggestions)

What this PR does: Improves the NUnit test runner reporting by (1) fixing summary counts to use NUnit aggregate results, (2) adding dry-run discovery mode, (3) adding noexclusions=true for auditing, (4) surfacing excluded tests as Ignored with explicit reasons, and (5) overwriting logcat per run.

The overall approach is sound — moving from NUnit filter-based exclusions to RunState.Ignored with skip reasons is the right direction for auditing and observability.

Issues

Severity Count Summary
⚠️ Warning 1 TestNameMatches .Contains() checks are overly broad and could match unintended tests
💡 Suggestion 2 Dead counter increments in TestFinished; repeated .Trim() calls

Positive callouts

  • Clean separation of concerns between ApplyIgnoredExclusions, UpdateDiscoveredTestCounts, and ApplyDryRunToMatchingTests
  • Good guard clauses in AddExcludedCategory/AddExcludedTestName
  • The noexclusions=true correctly bypasses only built-in exclusions while still honoring user-supplied extras — the right semantics for auditing
  • Logcat overwrite (StdoutAppend = false) is a welcome improvement for debugging stale crashes

CI: Both public checks (license/cla, dotnet-android) are passing ✅

Generated by Android PR Reviewer for issue #11162 · ● 6.5M

Comment thread tests/TestRunner.NUnit/NUnitTestRunner.cs Outdated
Comment thread tests/TestRunner.NUnit/NUnitTestRunner.cs
Comment thread tests/TestRunner.Core/TestInstrumentation.cs Outdated
- Fix TestNameMatches to use word-boundary-aware Contains checks
  (prefix with '.' or '+') instead of bare Contains that could match
  mid-word substrings
- Remove dead counter increments in TestFinished since
  UpdateSummaryCounts overwrites them from the NUnit aggregate result
- Extract static ParseBool helper to eliminate repeated Trim() calls
  in ProcessArguments

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot `copilot-cli` or other AIs were used to author this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants