Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix edge cases with swiftTesting rule #1968

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

calda
Copy link
Collaborator

@calda calda commented Jan 27, 2025

This PR fixes edge cases I noticed with the new swiftTesting rule that would cause build failures or runtime issues. For example:

  • Adds @Suite(.serialized) by default to match the XCTest behavior where tests run serially by default. Existing tests may not expect to be ran concurrently. I saw issues related to this in Airbnb's test suite.
  • Adds import Foundation by default, since XCTest exports Foundation (common for test cases to rely on Foundation types)
  • Adds import UIKit if the file uses any UIKit symbols (common in tests for app codebases) since XCTest exports UIKit
  • Fixed lots of issues where operators would cause build failures. Some examples of invalid code that we were generating before include !foo == bar, !foo is Bar, try? foo == bar, etc. (should be (!(foo == bar), !(foo is Bar), (try? foo) == bar).

With these fixes, Airbnb's unit test suite builds, runs, and passes successfully after applying the swiftTesting rule (after also manually fixing a relatively reasonable number of more minor edge cases).

@calda calda force-pushed the cal--fix-swift-testing-edge-cases branch from ddc1590 to e4b9e60 Compare January 27, 2025 23:50
Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 98.36066% with 2 lines in your changes missing coverage. Please review.

Project coverage is 95.51%. Comparing base (5475c1b) to head (e4b9e60).

Files with missing lines Patch % Lines
Sources/Rules/SwiftTesting.swift 98.21% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1968   +/-   ##
========================================
  Coverage    95.51%   95.51%           
========================================
  Files          139      139           
  Lines        25505    25590   +85     
========================================
+ Hits         24360    24442   +82     
- Misses        1145     1148    +3     

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

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.

1 participant