fix: make the documented demo test command actually run tests - #456
Merged
Merged
Conversation
The demo's mandatory testing workflow documents
dotnet test csharp/PhoneNumbers.Demo.Tests -p:TargetFrameworks=net10.0
but PhoneNumbers.Demo.Tests declared the singular TargetFramework, so that
switch set an otherwise-unused property and promoted the project to a
cross-targeting outer build. The run discovered zero tests, printed "No test
is available in ...", and exited 0 -- a green result for a suite that never
ran, which is exactly the failure mode the workflow is meant to prevent.
Declare TargetFrameworks instead, matching PhoneNumbers.Test and
PhoneNumbers.Extensions.Test, so the switch overrides a real property. Also
warn in AGENTS.md that a zero-discovery run still exits 0.
The solution-wide command is unaffected: the demo projects aren't in
PhoneNumbers.slnx, and both solution test projects already multi-target.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #456 +/- ##
==========================================
+ Coverage 87.51% 87.68% +0.16%
==========================================
Files 43 43
Lines 3886 3889 +3
Branches 991 992 +1
==========================================
+ Hits 3401 3410 +9
+ Misses 280 276 -4
+ Partials 205 203 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ping the csproj The prior fix made PhoneNumbers.Demo.Tests declare TargetFrameworks (plural) purely so a copy-pasted -p:TargetFrameworks=net10.0 override - which does nothing useful here since this project only ever has one TFM - wouldn't turn the build into a no-op cross-targeting outer build. That permanently pays cross-targeting overhead for a project that will never multi-target, and reads as "designed to support multiple frameworks" to the next contributor. Drop the override from the one documented command that doesn't need it instead, and revert the csproj to the singular TargetFramework it always should have had. Same fix, smaller and pointed at the actual root cause.
twcclegg
force-pushed
the
fix/demo-test-command-runs-no-tests
branch
from
September 5, 2026 19:38
159ddf1 to
60444d2
Compare
The command this recommends is right, but the reason given for it was not. Passing -p:TargetFrameworks=net10.0 does not produce a cross-targeting outer build: the build log shows it compiling the inner bin/Debug/net10.0/PhoneNumbers.Demo.Tests.dll and VSTest running against it. What it actually does is stop xunit.runner.visualstudio's build assets from being applied, so the adapter never lands in the output directory - xunit.runner.reporters.netcoreapp10.dll and xunit.runner.utility.netcoreapp10.dll are present without the switch and absent with it. That is what VSTest's "Make sure that test discoverer & executors are registered" is telling us, and it is where the next person should look. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1NSXom6AbfgVknJDtfR9C
This was referenced Sep 10, 2026
Open
Closed
Open
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.
Problem
csharp/PhoneNumbers.Demo/AGENTS.mdmakes running the demo suite a mandatory step, with this command:dotnet test csharp/PhoneNumbers.Demo.Tests -p:TargetFrameworks=net10.0That command runs zero tests and exits 0:
PhoneNumbers.Demo.Testsdeclares the singular<TargetFramework>net10.0</TargetFramework>, so-p:TargetFrameworks=net10.0sets a property the project never reads and promotes the build to a cross-targeting outer build, where no tests are discovered. Becausedotnet testexits 0 on zero discovery, the result reads as a pass.The net effect is that anyone — human or agent — following the mandatory workflow gets a green light for a suite that never ran. That is the precise failure the workflow exists to prevent.
Fix
The
-p:TargetFrameworks=net10.0override is vestigial here — it's copy-pasted from the repo-root convention (wherePhoneNumbers.Test/PhoneNumbers.Extensions.Testgenuinely multi-targetnet8.0;net10.0and the switch does real work), butPhoneNumbers.Demo.Testsonly ever targetsnet10.0and gets nothing from declaring it plural. So the fix removes the override from the one documented command that doesn't need it, rather than reshaping the csproj into permanent cross-targeting form to tolerate a flag that shouldn't be there — that alternative would pay outer/inner cross-targeting build overhead forever for a project that will never multi-target, and reads as "designed to support multiple frameworks" to the next contributor.AGENTS.mdadditionally notes that a zero-discovery run still exits 0 regardless, so the count is worth checking either way.Verification
dotnet test csharp/PhoneNumbers.Demo.Tests -p:TargetFrameworks=net10.0dotnet test csharp/PhoneNumbers.Demo.Testsrestore/build --no-restore/test --no-build)CI (
build_and_run_demo_tests.yml) never passed-p:TargetFrameworksin the first place, so it was never exposed to this bug and isn't affected either way.Scope note: the repo-wide
dotnet test csharp/PhoneNumbers.slnx -p:TargetFrameworks=net10.0in the rootAGENTS.md,README.mdandCONTRIBUTING.mdis not affected — the demo projects aren't inPhoneNumbers.slnx, and both solution test projects genuinely multi-target, so the switch does real work there.