Skip to content

Replace fragile telemetry count assertions with property enumeration - #7317

Merged
nkolev92 merged 1 commit into
devfrom
dev-nkolev92-fix-telemetry-count-test
Apr 24, 2026
Merged

nkolev92 merged 1 commit into
devfrom
dev-nkolev92-fix-telemetry-count-test

Conversation

@nkolev92

@nkolev92 nkolev92 commented Apr 24, 2026 •

Copy link
Copy Markdown
Member

Bug

Fixes: Engineering

Description

Two RestoreCommandTests used exact Count.Should().Be(N) assertions on telemetry events:

  • ExecuteAsync_WithSinglePackage_WhenNoOping_PopulatesCorrectTelemetry (count 42)
  • ExecuteAsync_WithPartiallyPopulatedGlobalPackagesFolder_PopulatesNewlyInstalledPackagesTelemetry (count 50, should have been 51)

These break whenever concurrent PRs each add new telemetry properties (PR #7213 + PR #7307 race caused the current CI failure on dev).

Replaced both with the same dictionary + bidirectional set comparison pattern used by ExecuteAsync_WithSinglePackage_PopulatesCorrectTelemetry, which enumerates all expected properties and validates no extras or missing properties exist. This makes the tests merge-friendly — adding a new telemetry property only requires updating the expected property dictionary, not guessing a magic count number.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@nkolev92
nkolev92 requested a review from a team as a code owner April 24, 2026 00:53
@nkolev92 nkolev92 added the Engineering Changes related to the build infrastructure of the repo and that do not change product code label Apr 24, 2026
@nkolev92
nkolev92 requested review from kartheekp-ms and zivkan April 24, 2026 00:53
@nkolev92
nkolev92 enabled auto-merge (squash) April 24, 2026 00:56
Two RestoreCommandTests used exact Count.Should().Be(N) assertions on
telemetry events, which broke whenever concurrent PRs each added new
telemetry properties. Replace these with the same dictionary +
bidirectional set comparison pattern used by
ExecuteAsync_WithSinglePackage_PopulatesCorrectTelemetry, which
enumerates all expected properties and validates no extras/missing exist.

This makes the tests merge-friendly: adding a new property only
requires updating the test that fully enumerates properties, not
guessing a magic count number.

Co-authored-by: Copilot <[email protected]>
@nkolev92
nkolev92 force-pushed the dev-nkolev92-fix-telemetry-count-test branch from 59c4001 to 3c666fe Compare April 24, 2026 01:48
@nkolev92 nkolev92 changed the title Fix telemetry property count assertion after concurrent PR merges Replace fragile telemetry count assertions with property enumeration Apr 24, 2026
@nkolev92 nkolev92 mentioned this pull request Apr 24, 2026
1 of 3 tasks
@nkolev92
nkolev92 merged commit bac078b into dev Apr 24, 2026
17 of 18 checks passed
@nkolev92
nkolev92 deleted the dev-nkolev92-fix-telemetry-count-test branch April 24, 2026 20:18
Copilot AI pushed a commit that referenced this pull request Apr 24, 2026
)

PR #7213 added AnyPackageIdContainsNonAlphanumericDotDashOrUnderscoreCharacters
telemetry and updated the count from 49 to 50, but PR #7307 had already added
TargetFrameworks and TargetFrameworksCount, making the correct count 51.

Co-authored-by: Copilot <[email protected]>
Co-authored-by: nkolev92 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Engineering Changes related to the build infrastructure of the repo and that do not change product code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants