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,31 +141,32 @@ 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
151
151
For more details on `Issue`, refer to the [Issue Documentation](https://developer.apple.com/documentation/testing/issue).
152
152
153
153
This revision aims to clarify the functionality and usage of the `Severity` enum and `Issue` properties while maintaining consistency with the existing Swift API standards.
154
154
155
-
### Integration with supporting tools
155
+
## Integration with supporting tools
156
+
157
+
### Event stream
156
158
157
159
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.
158
160
159
161
The JSON event stream ABI will be amended correspondingly:
160
162
161
-
```
162
-
<issue> ::= {
163
-
"isKnown": <bool>, ; is this a known issue or not?
164
-
+ "severity": <string>, ; the severity of the issue
165
-
+ "isFailure": <bool>, ; if the issue is a failing issue
166
-
["sourceLocation": <source-location>,] ; where the issue occurred, if known
167
-
}
163
+
```diff
164
+
<issue> ::= {
165
+
"isKnown": <bool>, ; is this a known issue or not?
166
+
+"severity": <string>, ; the severity of the issue
167
+
+"isFailure": <bool>, ; if the issue is a failing issue
168
+
["sourceLocation": <source-location>,] ; where the issue occurred, if known
169
+
}
168
170
```
169
171
170
172
Example of an `issueRecorded` event in the json output:
@@ -175,29 +177,21 @@ Example of an `issueRecorded` event in the json output:
175
177
176
178
### Console output
177
179
178
-
When there is an issue recorded with severity warning the output looks like this:
180
+
When there is an issue recorded with severity warning, such as using the following code:
179
181
180
182
```swift
181
-
Issue.record("My comment", severity: .warning)
182
-
```
183
-
184
-
```
185
-
Test "All elements of two ranges are equal" started.
186
-
Test "All elements of two ranges are equal" recorded a warning at ZipTests.swift:32:17: Issue recorded
187
-
My comment
188
-
Test "All elements of two ranges are equal" passed after 0.001 seconds with 1 warning.
183
+
Issue.record("My comment", severity: .warning)
189
184
```
190
185
191
-
### Trying this out
192
-
193
-
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.
190
+
� Test "All elements of two ranges are equal" recorded a warning at ZipTests.swift:32:17: Issue recorded
191
+
↳ My comment
192
+
✔ Test "All elements of two ranges are equal" passed after 0.001 seconds with 1 warning.
197
193
```
198
194
199
-
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:)
200
-
201
195
## Alternatives considered
202
196
203
197
- 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