Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Sources/Testing/Running/Runner.Plan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ extension Runner.Plan {
}
}

// If the test is parameterized but has no cases, mark it as skipped.
if case .run = action, let testCases = test.testCases, testCases.first(where: { _ in true }) == nil {
action = .skip(SkipInfo(comment: "No test cases found."))
}

actionGraph.updateValue(action, at: keyPath)

return test
Expand Down
18 changes: 18 additions & 0 deletions Tests/TestingTests/RunnerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ final class RunnerTests: XCTestCase {
await fulfillment(of: [testSkipped], timeout: 0.0)
}

func testParameterizedTestWithNoCasesIsSkipped() async throws {
let testSkipped = expectation(description: "Test was skipped")
var configuration = Configuration()
configuration.eventHandler = { event, _ in
if case .testSkipped = event.kind {
testSkipped.fulfill()
}
if case .testStarted = event.kind {
XCTFail("The test should not be reported as started.")
}
}
let runner = await Runner(testing: [
Test(arguments: Array<Int>(), parameters: [.init(index: 0, firstName: "i", type: Int.self)]) { _ in },
], configuration: configuration)
await runner.run()
await fulfillment(of: [testSkipped], timeout: 0.0)
}

func testTestIsSkippedWithBlockingEnabledIfTrait() async throws {
let testSkipped = expectation(description: "Test was skipped")
testSkipped.expectedFulfillmentCount = 4
Expand Down