You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is the `Issue.record` method definition with severity as a parameter.
78
79
79
80
```swift
81
+
extensionIssue {
82
+
// ...
83
+
80
84
/// Record an issue when a running test and an issue occurs.
81
85
///
82
86
/// - Parameters:
@@ -95,8 +99,7 @@ Here is the `Issue.record` method definition with severity as a parameter.
95
99
severity: Severity = .error,
96
100
sourceLocation: SourceLocation =#_sourceLocation
97
101
) ->Self
98
-
99
-
// ...
102
+
}
100
103
```
101
104
102
105
### Issue Type Enhancements
@@ -106,13 +109,11 @@ The Issue type is enhanced with two new properties to better handle and report i
106
109
-`severity`: This property allows access to the specific severity level of an issue, enabling more precise handling of test results.
107
110
108
111
```swift
109
-
// ...
110
-
111
112
extensionIssue {
113
+
// ...
112
114
113
-
/// The severity of the issue.
114
-
publicvar severity: Severity { getset }
115
-
115
+
/// The severity of the issue.
116
+
publicvar severity: Severity { getset }
116
117
}
117
118
118
119
```
@@ -140,11 +141,10 @@ extension Issue {
140
141
Example usage of `severity` and `isFailure`:
141
142
142
143
```swift
143
-
// ...
144
144
withKnownIssue {
145
145
// ...
146
146
} matching: { issue in
147
-
returnissue.isFailure|| issue.severity> .warning
147
+
issue.isFailure|| issue.severity> .warning
148
148
}
149
149
```
150
150
@@ -182,19 +182,21 @@ extension Issue {
182
182
}
183
183
```
184
184
185
-
### Integration with supporting tools
185
+
## Integration with supporting tools
186
+
187
+
### Event stream
186
188
187
189
Issue severity will be in the event stream output when a `issueRecorded` event occurs. This will be a breaking change because some tools may assume that all `issueRecorded` events are failing. Due to this we will be bumping the event stream version and v1 will maintain it's behavior and not output any events for non failing issues. We will also be adding `isFailure` to the issue so that clients will know if the issue should be treated as a failure. `isFailure` is a computed property.
188
190
189
191
The JSON event stream ABI will be amended correspondingly:
190
192
191
-
```
192
-
<issue> ::= {
193
-
"isKnown": <bool>, ; is this a known issue or not?
194
-
+ "severity": <string>, ; the severity of the issue
195
-
+ "isFailure": <bool>, ; if the issue is a failing issue
196
-
["sourceLocation": <source-location>,] ; where the issue occurred, if known
197
-
}
193
+
```diff
194
+
<issue> ::= {
195
+
"isKnown": <bool>, ; is this a known issue or not?
196
+
+"severity": <string>, ; the severity of the issue
197
+
+"isFailure": <bool>, ; if the issue is a failing issue
198
+
["sourceLocation": <source-location>,] ; where the issue occurred, if known
199
+
}
198
200
```
199
201
200
202
Example of an `issueRecorded` event in the json output:
@@ -205,29 +207,21 @@ Example of an `issueRecorded` event in the json output:
205
207
206
208
### Console output
207
209
208
-
When there is an issue recorded with severity warning the output looks like this:
210
+
When there is an issue recorded with severity warning, such as using the following code:
209
211
210
212
```swift
211
-
Issue.record("My comment", severity: .warning)
212
-
```
213
-
214
-
```
215
-
Test "All elements of two ranges are equal" started.
216
-
Test "All elements of two ranges are equal" recorded a warning at ZipTests.swift:32:17: Issue recorded
217
-
My comment
218
-
Test "All elements of two ranges are equal" passed after 0.001 seconds with 1 warning.
213
+
Issue.record("My comment", severity: .warning)
219
214
```
220
215
221
-
### Trying this out
222
-
223
-
To use severity today, checkout the branch here: https://github.com/swiftlang/swift-testing/pull/1189
◇ Test "All elements of two ranges are equal" started.
220
+
� Test "All elements of two ranges are equal" recorded a warning at ZipTests.swift:32:17: Issue recorded
221
+
↳ My comment
222
+
✔ Test "All elements of two ranges are equal" passed after 0.001 seconds with 1 warning.
227
223
```
228
224
229
-
For more details on how to checkout a branch for a package refer to this: https://developer.apple.com/documentation/packagedescription/package/dependency/package(url:branch:)
230
-
231
225
## Alternatives considered
232
226
233
227
- Separate Issue Creation and Recording: We considered providing a mechanism to create issues independently before recording them, rather than passing the issue details directly to the `record` method. This approach was ultimately set aside in favor of simplicity and directness in usage.
0 commit comments