diff --git a/Sources/XcodeGraph/Models/TestableTarget.swift b/Sources/XcodeGraph/Models/TestableTarget.swift index 7d800202..aa01d488 100644 --- a/Sources/XcodeGraph/Models/TestableTarget.swift +++ b/Sources/XcodeGraph/Models/TestableTarget.swift @@ -3,27 +3,61 @@ import Path /// Testable target describe target and tests information. public struct TestableTarget: Equatable, Hashable, Codable, Sendable { + /// With the introduction of Swift Testing and Xcode 16, you can now choose to run your tests + /// in parallel across either the full suite of tests in a target with `.all`, just those created + /// under Swift Testing with `.swiftTestingOnly`, or run them serially with the `.none` option. + public enum Parallelization: Equatable, Hashable, Codable, Sendable { + case none, swiftTestingOnly, all + } + /// The target name and its project path. public let target: TargetReference /// Skip test target from TestAction. public let isSkipped: Bool + /// Execute tests in parallel. - public let isParallelizable: Bool + @available( + *, + deprecated, + renamed: "parallelization", + message: "isParallelizable was deprecated. Use the paralellization property instead." + ) + public var isParallelizable: Bool { + parallelization == .none + } + + public let parallelization: Parallelization + /// Execute tests in random order. public let isRandomExecutionOrdering: Bool /// A simulated location used when testing this test target. public let simulatedLocation: SimulatedLocation? + @available(*, deprecated, renamed: "init(target:skipped:parallelization:randomExecutionOrdering:simulatedLocation:)") + public init( + target: TargetReference, + skipped: Bool = false, + parallelizable: Bool, + randomExecutionOrdering: Bool = false, + simulatedLocation: SimulatedLocation? = nil + ) { + self.target = target + isSkipped = skipped + parallelization = parallelizable ? .all : .none + isRandomExecutionOrdering = randomExecutionOrdering + self.simulatedLocation = simulatedLocation + } + public init( target: TargetReference, skipped: Bool = false, - parallelizable: Bool = false, + parallelization: Parallelization = .none, randomExecutionOrdering: Bool = false, simulatedLocation: SimulatedLocation? = nil ) { self.target = target isSkipped = skipped - isParallelizable = parallelizable + self.parallelization = parallelization isRandomExecutionOrdering = randomExecutionOrdering self.simulatedLocation = simulatedLocation } diff --git a/Tests/XcodeGraphTests/Models/TestableTargetTests.swift b/Tests/XcodeGraphTests/Models/TestableTargetTests.swift index 2332fb21..ea780400 100644 --- a/Tests/XcodeGraphTests/Models/TestableTargetTests.swift +++ b/Tests/XcodeGraphTests/Models/TestableTargetTests.swift @@ -5,7 +5,7 @@ import XCTest @testable import XcodeGraph final class TestableTargetTests: XCTestCase { - func test_codable() { + func test_codable_with_deprecated_parallelizable() { // Given let subject = TestableTarget( target: .init( @@ -20,4 +20,20 @@ final class TestableTargetTests: XCTestCase { // Then XCTAssertCodable(subject) } + + func test_codable() { + // Given + let subject = TestableTarget( + target: .init( + projectPath: try! AbsolutePath(validating: "/path/to/project"), + name: "name" + ), + skipped: true, + parallelization: .all, + randomExecutionOrdering: true + ) + + // Then + XCTAssertCodable(subject) + } }