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
17 changes: 10 additions & 7 deletions Sources/Testing/ABI/Encoded/ABI.EncodedEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,35 +67,38 @@ extension ABI {
/// `testStarted`/`testEnded` events, and replace `testCaseStarted`/
/// `testCaseEnded` with `testStarted`/`testEnded`.
/// - For parameterized tests, emit all events.
let isNonParameterizedTest = eventContext.test?.isParameterized == false
var isNonParameterizedTestFunction = false
if let test = eventContext.test, !test.isSuite {
isNonParameterizedTestFunction = !test.isParameterized
}

switch kind {
case .runStarted:
self = .runStarted
case .testStarted:
if isNonParameterizedTest {
if isNonParameterizedTestFunction {
return nil
}
self = .testStarted
case .testCaseStarted:
self = isNonParameterizedTest ? .testStarted : .testCaseStarted
self = isNonParameterizedTestFunction ? .testStarted : .testCaseStarted
case .issueRecorded:
self = .issueRecorded
case .valueAttached:
self = .valueAttached
case .testCaseEnded:
self = isNonParameterizedTest ? .testEnded : .testCaseEnded
self = isNonParameterizedTestFunction ? .testEnded : .testCaseEnded
case .testCaseCancelled:
self = isNonParameterizedTest ? .testCancelled : .testCaseCancelled
self = isNonParameterizedTestFunction ? .testCancelled : .testCaseCancelled
case .testEnded:
if isNonParameterizedTest {
if isNonParameterizedTestFunction {
return nil
}
self = .testEnded
case .testSkipped:
self = .testSkipped
case .testCancelled:
if isNonParameterizedTest {
if isNonParameterizedTestFunction {
return nil
}
self = .testCancelled
Expand Down
8 changes: 8 additions & 0 deletions Tests/TestingTests/ABI.EncodedTestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,13 @@

#expect(test.decodeIDComponents() == nil)
}

@Test func `Can encode an event for a test suite`() {
let test = Test(traits: [], sourceLocation: .__here(), containingTypeInfo: TypeInfo(describing: Int.self))
let event = Event(.testStarted, testID: test.id, testCaseID: nil)
let eventContext = Event.Context(test: test, testCase: nil, iteration: 1, configuration: nil)
let encodedEvent = ABI.EncodedEvent<ABI.CurrentVersion>(encoding: event, in: eventContext, messages: [])
#expect(encodedEvent != nil)
}
#endif
}
Loading