Repository navigation
Tests: no test may pass by returning from a catch block - #5254
Merged
Merged
Conversation
Replace the dead return after Assert.Skip with a rethrow so the skip is the only exit, add a junction case for the certificate path that needs no privilege, and add a guard that fails on a bare return in a catch of a test.
This was referenced Oct 5, 2026
erikdarlingdata
marked this pull request as ready for review
October 5, 2026 14:52
12 of 14 tasks
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.
A test of the form
try { setup(); } catch { return; }is reported as a pass, not a skip, so where the setup cannot run it asserts nothing and still reads as coverage. A Windows run of a symlink test reported "0 skipped" this way, when creating a symbolic link needs a privilege an ordinary session lacks.What changed
return;inside acatch. Five wereAssert.Skip(...)followed by a deadreturn;(xunit v3'sAssert.Skipthrows, so these already skipped honestly). The deadreturn;is gone, so a skip is the only exit. Where the compiler then neededprocassigned, the catch rethrows after the skip call.WebModuleLoadTestsis a real test, so it got the same treatment. Three more tests with the same shape turned up when the new guard ran (WebCollectionHealthRunAtColumnTests,WebDatabaseSizesNoteColumnTests,AzureSqlDatabaseHardwareTests) and got the same fix.StoreThatRefusesTheLogin_ExitsWithTheStoreCodereturns from a catch inside a listener helper loop, not from the test, so it is left alone.File.ResolveLinkTarget(..., returnFinalTarget: true)) before asserting the refusal.ExportViewerConfigAsync_JunctionAtTheDestinationOrTheCertificatePath_RefusesWithoutWritingThrough: a directory junction (mklink /J) needs no privilege, so this case cannot skip for want of a right. It asserts the junction exists and resolves, then that the export refuses and writes nothing through it, for a junction as the destination and a junction atserver.crt.TestsNoSilentPassGuardTests: scans both test projects and fails if any[Fact]/[Theory]has a barereturn;inside acatch. The message namesAssert.Skip/Assert.SkipUnless. It has a self-test of the scanner and no exemption list.Verified
ResolveViewerExportDirectory_*path tests (Windows paths) andLivePostgresCollectionHygieneTests. They fail on dev too.server.crthas the ReparsePoint attribute, so it takes the symbolic-link refusal at :1672. Not run.CHANGELOG entry
SECTION: None
ENTRY: None: test-only change, no user-visible effect