Skip to content

Run the tests solution wide, locally and in CI - #1119

Merged
SimonCropp merged 2 commits into
mainfrom
exclude-trx-helper-from-dotnet-test
Oct 11, 2026
Merged

SimonCropp merged 2 commits into
mainfrom
exclude-trx-helper-from-dotnet-test

Conversation

@SimonCropp

@SimonCropp SimonCropp commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

What

Two commits: a solution wide dotnet test now passes, and CI uses it.

CI. The Test step is one command in place of the loop that ran seven projects in turn and deleted every LocalDB instance in between:

dotnet test --solution src/LocalDb.slnx --configuration Release --no-build --no-restore
  • The test projects now run in parallel, with nothing deleted between them. The old comment said instances collide when left behind. Three solution wide runs passed locally, but CI has unprefixed instance names and a different LocalDB version, so this PR's own run is the real test of it.
  • LoadTest is now part of the CI run; it was not in the old list. Its 100 tests are explicit, so they are skipped and it reports as passed.
  • New test projects are picked up without a list to maintain.

Helper. EfLocalDb.ReportTrxHelper is no longer run by dotnet test, which is what made a solution wide run fail.

  • New src/EfLocalDb.ReportTrxHelper/Directory.Build.targets sets IsTestingPlatformApplication to false.
  • EfLocalDb.ReportTrxHelper.csproj sets GenerateTestingPlatformEntryPoint and GenerateSelfRegisteredExtensions to true explicitly, since both default to that property. The helper is still the same testing platform executable, with the generated Main and the TRX extension registered.

Why

A solution wide dotnet test --solution src/LocalDb.slnx failed even when every test passed:

EfLocalDb.ReportTrxHelper.dll (net10.0|x64) Zero tests ran (282ms)
Exit code: 8
...
Test run summary: Failed!
  total: 570
  failed: 0
  succeeded: 469
  skipped: 101
Test run completed with non-success exit code: 8

The helper hosts no tests. ReportTrxGuardTests launches it to prove the guard, and its project file already says IsTestProject=false. Under Microsoft.Testing.Platform that is not what dotnet test looks at: it runs any project where IsTestingPlatformApplication is true, and NUnit3TestAdapter.targets assigns that from EnableNUnitRunner unconditionally.

That is also why the override is in a Directory.Build.targets rather than in the project file. Package targets are imported after the project file's own properties, so a value set there is overwritten. Directory.Build.targets is imported after the package targets.

CI never hit this, since it ran a fixed list of projects one at a time. With the helper excluded it can run the solution, as a developer does.

Verified

  • Solution wide dotnet test, Debug, before: exit code 8, "Failed!", as above.
  • Solution wide dotnet test, Debug, after: exit code 0, "Passed!", 469 passed, 0 failed, 101 skipped, and the helper is not listed.
  • The helper launched directly with --report-trx still exits non zero with the guard's message.
  • ReportTrxGuardTests pass (7 of 7) in Debug and in Release, which is what CI builds.
  • The property evaluates to false in both configurations.

Not run: the full suite in Release. CI will do that here.

Alternative considered

The guard only reads the command line and the call stack, so the helper could be a plain console app with no NUnit or TRX packages, and would then never be mistaken for a test project. I kept it as a real test host because that looked deliberate.

Correction to #1118

That PR's description said a solution wide dotnet test failed locally with instance contention errors (Could not obtain exclusive lock on database 'model', dropped pipes), and that I had not checked whether main did the same. It does not. The failure was two of my own solution wide runs overlapping on the same LocalDB instances: the first had been cut short on screen by a Select-Object -First in the pipeline but kept running in the background. Running one project twice at once reproduces those errors; a single clean run passes.

A solution wide dotnet test ran EfLocalDb.ReportTrxHelper as a test project, found zero tests, and failed the whole run with exit code 8 even when every test passed. The helper already sets IsTestProject=false, but under Microsoft.Testing.Platform dotnet test goes by IsTestingPlatformApplication, which NUnit3TestAdapter's targets assign from EnableNUnitRunner unconditionally.

Set it to false in a Directory.Build.targets beside the project, which is imported after package targets and so is not overwritten. The entry point and extension registration default to that property, so they are now turned on explicitly and the helper stays the same testing platform executable.
One dotnet test over the solution replaces the loop that ran each project in turn and deleted every LocalDB instance in between. It runs the projects in parallel, picks up new test projects without a list to maintain, and is what a developer runs locally.
@SimonCropp SimonCropp changed the title Keep the ReportTrx helper out of dotnet test Run the tests solution wide, locally and in CI Oct 11, 2026
@SimonCropp
SimonCropp merged commit 07585ab into main Oct 11, 2026
4 checks passed
@SimonCropp
SimonCropp deleted the exclude-trx-helper-from-dotnet-test branch October 11, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant