Skip to content

Avoid passive voice and clarify macro in exit test docs. #1243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
21 changes: 13 additions & 8 deletions Sources/Testing/Testing.docc/exit-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@ func `Customer won't eat food unless it's nutritious`(_ food: Food) async {
}
```

- Note: If you use this macro with a Swift compiler version lower than 6.3, it
doesn't support capturing state.
- Note: If you use ``expect(processExitsWith:observing:_:sourceLocation:performing:)``
or ``require(processExitsWith:observing:_:sourceLocation:performing:)`` with a
Swift compiler version lower than 6.3, the macro doesn't capture state.

If a captured value is an argument to the current function or is `self`, its
type is inferred at compile time. Otherwise, explicitly specify the type of the
If a captured value is an argument to the current function or is `self`, the
compiler infers the value's type. Otherwise, explicitly specify the type of the
value using the `as` operator:

```swift
Expand All @@ -126,10 +127,14 @@ value using the `as` operator:
```

Every value you capture in an exit test must conform to [`Sendable`](https://developer.apple.com/documentation/swift/sendable)
and [`Codable`](https://developer.apple.com/documentation/swift/codable). Each
value is encoded by the parent process using [`encode(to:)`](https://developer.apple.com/documentation/swift/encodable/encode(to:))
and is decoded by the child process [`init(from:)`](https://developer.apple.com/documentation/swift/decodable/init(from:))
before being passed to the exit test body.
and [`Codable`](https://developer.apple.com/documentation/swift/codable). The
testing library passes each value to the exit test body by following this process:

1. It encodes each value using [`encode(to:)`](https://developer.apple.com/documentation/swift/encodable/encode(to:))
in the parent process
2. It passes the encoded value to the child process
3. It decodes each value using [`init(from:)`](https://developer.apple.com/documentation/swift/decodable/init(from:))
in the child process

If a captured value's type does not conform to both `Sendable` and `Codable`, or
if the value is not explicitly specified in the exit test body's capture list,
Expand Down