diff --git a/Sources/XcodeProj/Scheme/XCScheme+TestableReference.swift b/Sources/XcodeProj/Scheme/XCScheme+TestableReference.swift index 39a4696b..23c5413b 100644 --- a/Sources/XcodeProj/Scheme/XCScheme+TestableReference.swift +++ b/Sources/XcodeProj/Scheme/XCScheme+TestableReference.swift @@ -33,6 +33,24 @@ public extension XCScheme { self.selectedTests = selectedTests self.skippedTests = skippedTests } + + public init(skipped: Bool, + parallelizable: Bool = false, + randomExecutionOrdering: Bool = false, + buildableReference: BuildableReference, + locationScenarioReference: LocationScenarioReference? = nil, + skippedTests: [TestItem] = [], + selectedTests: [TestItem] = [], + useTestSelectionWhitelist: Bool? = nil) { + self.skipped = skipped + self.parallelizable = parallelizable ? .all : .none + self.randomExecutionOrdering = randomExecutionOrdering + self.buildableReference = buildableReference + self.locationScenarioReference = locationScenarioReference + self.useTestSelectionWhitelist = useTestSelectionWhitelist + self.selectedTests = selectedTests + self.skippedTests = skippedTests + } init(element: AEXMLElement) throws { skipped = element.attributes["skipped"] == "YES" diff --git a/Tests/XcodeProjTests/Scheme/XCSchemeTests.swift b/Tests/XcodeProjTests/Scheme/XCSchemeTests.swift index 83a32735..6930fc80 100644 --- a/Tests/XcodeProjTests/Scheme/XCSchemeTests.swift +++ b/Tests/XcodeProjTests/Scheme/XCSchemeTests.swift @@ -58,6 +58,12 @@ final class XCSchemeIntegrationTests: XCTestCase { } } + func test_read_iosScheme_noParallelizable_setsswiftTestingOnly() throws { + let scheme = try XCScheme(path: iosSchemePath) + + XCTAssertEqual(scheme.testAction?.testables.first?.parallelizable, .swiftTestingOnly) + } + func test_write_minimalScheme() { testWrite(from: minimalSchemePath, initModel: { try? XCScheme(path: $0) }, @@ -85,7 +91,7 @@ final class XCSchemeIntegrationTests: XCTestCase { XCTAssertNil(subject.attributes["useTestSelectionWhitelist"]) } - func test_write_testableReferenceAttributesValues() { + func test_write_testableReferenceAttributesValues_allParallelizable() { let reference = XCScheme.TestableReference( skipped: false, parallelizable: .all, @@ -106,28 +112,72 @@ final class XCSchemeIntegrationTests: XCTestCase { XCTAssertEqual(subject.attributes["useTestSelectionWhitelist"], "YES") XCTAssertEqual(subject.attributes["testExecutionOrdering"], "random") } - - func test_write_testableReferenceAttributesValuesForSwiftTesting() { - let reference = XCScheme.TestableReference( - skipped: false, - parallelizable: .swiftTestingOnly, - randomExecutionOrdering: true, - buildableReference: XCScheme.BuildableReference( - referencedContainer: "", - blueprint: PBXObject(), - buildableName: "", - blueprintName: "" - ), - skippedTests: [], - selectedTests: [], - useTestSelectionWhitelist: true - ) - let subject = reference.xmlElement() - XCTAssertEqual(subject.attributes["skipped"], "NO") - XCTAssertNil(subject.attributes["parallelizable"]) - XCTAssertEqual(subject.attributes["useTestSelectionWhitelist"], "YES") - XCTAssertEqual(subject.attributes["testExecutionOrdering"], "random") - } + + func test_write_testableReferenceAttributesValues_noneParallelizable() { + let reference = XCScheme.TestableReference( + skipped: false, + parallelizable: .none, + randomExecutionOrdering: true, + buildableReference: XCScheme.BuildableReference( + referencedContainer: "", + blueprint: PBXObject(), + buildableName: "", + blueprintName: "" + ), + skippedTests: [], + selectedTests: [], + useTestSelectionWhitelist: true + ) + let subject = reference.xmlElement() + XCTAssertEqual(subject.attributes["skipped"], "NO") + XCTAssertEqual(subject.attributes["parallelizable"], "NO") + XCTAssertEqual(subject.attributes["useTestSelectionWhitelist"], "YES") + XCTAssertEqual(subject.attributes["testExecutionOrdering"], "random") + } + + func test_write_testableReferenceAttributesValues_trueParallelizable() { + let reference = XCScheme.TestableReference( + skipped: false, + parallelizable: true, + randomExecutionOrdering: true, + buildableReference: XCScheme.BuildableReference( + referencedContainer: "", + blueprint: PBXObject(), + buildableName: "", + blueprintName: "" + ), + skippedTests: [], + selectedTests: [], + useTestSelectionWhitelist: true + ) + let subject = reference.xmlElement() + XCTAssertEqual(subject.attributes["skipped"], "NO") + XCTAssertEqual(subject.attributes["parallelizable"], "YES") + XCTAssertEqual(subject.attributes["useTestSelectionWhitelist"], "YES") + XCTAssertEqual(subject.attributes["testExecutionOrdering"], "random") + } + + func test_write_testableReferenceAttributesValues_falseParallelizable() { + let reference = XCScheme.TestableReference( + skipped: false, + parallelizable: false, + randomExecutionOrdering: true, + buildableReference: XCScheme.BuildableReference( + referencedContainer: "", + blueprint: PBXObject(), + buildableName: "", + blueprintName: "" + ), + skippedTests: [], + selectedTests: [], + useTestSelectionWhitelist: true + ) + let subject = reference.xmlElement() + XCTAssertEqual(subject.attributes["skipped"], "NO") + XCTAssertEqual(subject.attributes["parallelizable"], "NO") + XCTAssertEqual(subject.attributes["useTestSelectionWhitelist"], "YES") + XCTAssertEqual(subject.attributes["testExecutionOrdering"], "random") + } func test_write_testableReferenceSelectedTests() { // Given