Skip to content

Commit 3f73ced

Browse files
authored
Don't emit JSON blobs for test cases if a test function isn't parameterized. (#482)
Internally, Swift Testing models non-parameterized test functions as parameterized over a single input, `()`. This is a very useful abstraction internally, but when it comes to the JSON output for parameterized tests, it can be confusing or surprising to see information about a test case that was synthesized by the library. This PR suppresses events and metadata for the single test case of a non-parameterized test function. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 375b4c2 commit 3f73ced

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Sources/Testing/EntryPoints/ABIv0/Encoded/ABIv0.EncodedEvent.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,17 @@ extension ABIv0 {
6464
case .testStarted:
6565
kind = .testStarted
6666
case .testCaseStarted:
67+
if eventContext.test?.isParameterized == false {
68+
return nil
69+
}
6770
kind = .testCaseStarted
6871
case let .issueRecorded(recordedIssue):
6972
kind = .issueRecorded
7073
issue = EncodedIssue(encoding: recordedIssue)
7174
case .testCaseEnded:
75+
if eventContext.test?.isParameterized == false {
76+
return nil
77+
}
7278
kind = .testCaseEnded
7379
case .testEnded:
7480
kind = .testEnded
@@ -82,7 +88,9 @@ extension ABIv0 {
8288
instant = EncodedInstant(encoding: event.instant)
8389
self.messages = messages.map(EncodedMessage.init)
8490
testID = event.testID.map(EncodedTest.ID.init)
85-
_testCase = eventContext.testCase.map(EncodedTestCase.init)
91+
if eventContext.test?.isParameterized == true {
92+
_testCase = eventContext.testCase.map(EncodedTestCase.init)
93+
}
8694
}
8795
}
8896
}

0 commit comments

Comments
 (0)