Skip to content

Deduplicate default suite attributes in preferSwiftTesting - #2699

Merged
calda merged 1 commit into
developfrom
copilot/fix-prefer-swift-testing-edge-case
Sep 21, 2026
Merged

calda merged 1 commit into
developfrom
copilot/fix-prefer-swift-testing-edge-case

Conversation

Copilot AI commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

preferSwiftTesting was appending --default-test-suite-attributes even when a suite already declared the same attribute, producing duplicate annotations (e.g. two @MainActor lines). This change makes attribute insertion idempotent for existing suite-level attributes.

  • Rule behavior update

    • Filter defaultTestSuiteAttributes against attributes already present on the XCTest suite declaration before insertion.
    • Preserve configured defaults that are missing; skip only duplicates.
  • Regression coverage

    • Added a test for an XCTest suite already annotated with @MainActor while defaultTestSuiteAttributes: ["@MainActor"] is set.
    • Expected output now keeps a single @MainActor on the converted Swift Testing suite.
// Before (incorrect)
@MainActor
@MainActor
final class MyFeatureTests { ... }

// After
@MainActor
final class MyFeatureTests { ... }

Co-authored-by: calda <1811727+calda@users.noreply.github.com>
Copilot AI changed the title Fix duplicate default suite attributes in preferSwiftTesting Deduplicate default suite attributes in preferSwiftTesting Sep 21, 2026
Copilot AI requested a review from calda September 21, 2026 21:08
@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.45%. Comparing base (e2344b0) to head (e898d15).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2699      +/-   ##
===========================================
+ Coverage    95.44%   95.45%   +0.01%     
===========================================
  Files          182      182              
  Lines        27933    27936       +3     
===========================================
+ Hits         26660    26666       +6     
+ Misses        1273     1270       -3     

☔ View full report in Codecov by Harness.
📢 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.

@calda
calda marked this pull request as ready for review September 21, 2026 21:20
@calda
calda merged commit 056f0fc into develop Sep 21, 2026
19 checks passed
@calda
calda deleted the copilot/fix-prefer-swift-testing-edge-case branch September 21, 2026 21:21
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.

2 participants