Skip to content

[Bug]: Every "not elevated" test silently passes on CI, and one integration test has no assertion at all #2102

Description

@laurentiu021

Problem

Sixteen test cases that exist to pin admin-gated behaviour assert nothing where they run, because each one opens by skipping itself on an elevated host — and the CI runner is elevated. The repo already knows this: EtwBandwidthSourceTests.cs:213 carries the comment // elevated CI runner: the negative path is moot.

Six guard sites:

File Cases
SysManager.Tests/CleanupViewModelTests.cs:205,218 2 — SFC and DISM refuse without admin
SysManager.Tests/EtwBandwidthSourceTests.cs:213 1
SysManager.IntegrationTests/WindowsUpdateViewModelTests.cs:96,108 2 (project is never executed at all, see #2101)
SysManager.UITests/AdminBannerUiTests.cs:45 9 — the whole privileged-tab banner net, in a warning-only job

The main workstation cannot run dotnet test, so no environment in the project executes the branch these tests were written for. The elevation gate on SFC, DISM, Windows Update and the nine privileged tabs is effectively unpinned.

CleanupViewModel makes it worse by asking twice: line 77 seeds an IsElevated property from AdminHelper.IsElevated(), while the command guards at 309 and 416 call the static again. A test cannot influence either.

Separately: an integration test with no assertion

SysManager.IntegrationTests/InfrastructureTests.cs:144WingetService_EventForwardingWorks subscribes to LineReceived, fetches a FieldInfo and discards it, then discards the flag with _ = gotLine;. It constructs a real PowerShellRunner, asserts nothing, and always passes. Its own comments admit it: "We accept that this path requires a running session; skip if not possible."

Expected behavior

Elevation is a dependency, not an ambient fact, so a test can state it. Route AdminHelper.IsElevated() through a seam the way TimeProvider handles the clock — one injectable/overridable source, consumed everywhere including the command guards — and the negative path becomes deterministic on any host, elevated or not. Then the skip guards come out and the assertions run everywhere.

WingetService_EventForwardingWorks either asserts that a line raised on the runner reaches the service's subscribers, or it is deleted. A test that cannot fail is worse than no test: it reports coverage it does not have.

Evidence

Guard sites from grep -rn 'IsElevated()' --include=*.cs across all three test projects, excluding obj/.

Affected area

Test suite (Cleanup, Windows Update, Bandwidth Monitor, the 9 privileged tabs)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions