Skip to content

Conversation

@calda
Copy link
Member

@calda calda commented Oct 22, 2025

Summary

This PR proposes a new test suite access control rule. In a test suite, test cases should be internal and other properties / helpers should be private.

Reasoning

Test suites and test cases don't need to be public to be picked up by XCTest / Swift Testing.

Helpers and stored properties should be private since they are not accessed outside of the test case.

import Testing

// WRONG
struct SpaceshipTests {
  let spaceship = Spaceship()

  func launchSpaceship() {
    spaceship.launch()
  }

  @Test
  func spaceshipCanLaunch() {
    launchSpaceship()
    #expect(spaceship.hasLaunched)
  }
}

// RIGHT
struct SpaceshipTests {

  // MARK: Internal

  @Test
  func spaceshipCanLaunch() {
    launchSpaceship()
    #expect(spaceship.hasLaunched)
  }

  // MARK: Private

  private let spaceship = Spaceship()

  private func launchSpaceship() {
    spaceship.launch()
  }

}

@calda calda force-pushed the cal--testCaseAccessControl branch from 0e61b6e to 4cb3cf7 Compare October 22, 2025 19:10
@calda calda force-pushed the cal--testCaseAccessControl branch from 4cb3cf7 to 9a2ae71 Compare October 22, 2025 19:10
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