Skip to content

Fix TheoryDataRow traits not discovered in UI theory discoverers - #183

Merged
AArnott merged 2 commits into
mainfrom
copilot/fix-wpf-theory-discovery
Apr 24, 2026
Merged

AArnott merged 2 commits into
mainfrom
copilot/fix-wpf-theory-discovery

Conversation

Copilot AI commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Traits set via TheoryDataRow.WithTrait() were silently dropped during test discovery for WpfTheory, StaTheory, UITheory, and WinFormsTheory, causing --filter-trait to return zero tests.

Root cause

Utilities.CreateTestCaseForDataRow called a private GetTraits(testMethod) that only read testMethod.Traits, ignoring traits on the ITheoryDataRow itself.

Fix

  • Sdk/Utilities.cs: Replace GetTraits(testMethod) with TestIntrospectionHelper.GetTraits(testMethod, dataRow) in CreateTestCaseForDataRow — the xunit-provided overload that merges method-level and data-row-level traits.

Tests

Added TheoryDataRowTraitsAreDiscovered to each affected theory test class using:

public static IEnumerable<TheoryDataRow<string>> TraitDataRows =>
[
    new TheoryDataRow<string>("hello")
        .WithTrait("rowid", "properties"),
];

[UITheory]
[MemberData(nameof(TraitDataRows))]
public void TheoryDataRowTraitsAreDiscovered(string s) { ... }

Running -- --filter-trait "rowid=properties" now correctly discovers and runs these tests.

Copilot AI changed the title [WIP] Fix WpfTheory not discovering traits in tests Fix TheoryDataRow traits not discovered in UI theory discoverers Apr 24, 2026
Copilot AI requested a review from AArnott April 24, 2026 13:26
@AArnott
AArnott marked this pull request as ready for review April 24, 2026 14:22
@AArnott
AArnott enabled auto-merge (squash) April 24, 2026 14:24
@codecov-commenter

codecov-commenter commented Apr 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.55%. Comparing base (64640e4) to head (c590e2a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #183   +/-   ##
=======================================
  Coverage   83.55%   83.55%           
=======================================
  Files          36       36           
  Lines         742      742           
  Branches       64       64           
=======================================
  Hits          620      620           
  Misses        100      100           
  Partials       22       22           
Flag Coverage Δ
Linux 80.43% <100.00%> (ø)
Windows 79.11% <100.00%> (ø)
macOS 80.43% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AArnott
AArnott merged commit 29dfdae into main Apr 24, 2026
4 checks passed
@AArnott
AArnott deleted the copilot/fix-wpf-theory-discovery branch April 24, 2026 14:26
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.

WpfTheory (WpfTheoryDiscoverer?) doesn't seem to discover traits

3 participants