Skip to content
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

API or mechanism to perform an action once before/after running all of the tests in a suite type #36

Open
stmontgomery opened this issue Sep 28, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request public-api Affects public API

Comments

@stmontgomery
Copy link
Contributor

Description

We should have an API or mechanism to perform an action once inside a suite type before or after running all of that suite's tests.

Conceptually, this would be similar to XCTest's class-level +setUp and +tearDown APIs, or what some other testing libraries call "BeforeAll" and "AfterAll". However, for a more modern Swift solution, it may be better to use a closure- or scoped access- style API, since that interoperates better with Swift concurrency and allows using @TaskLocal.

rdar://103616215

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

No response

swift-testing version/commit hash

No response

Swift & OS version (output of swift --version && uname -a)

No response

@stmontgomery stmontgomery added the enhancement New feature or request label Sep 28, 2023
@stmontgomery stmontgomery self-assigned this Sep 28, 2023
@grynspan
Copy link
Contributor

I think the right basic shape for this is some protocol, i.e.:

protocol CustomWhateverable {
static func beforeAll(in suiteType: Self.Type) async throws
static func afterAll(in suiteType: Self.Type) async throws
}

Or something like that. Runner can then detect that a suite type conforms to this protocol and, if so, trivially call those functions at the appropriate times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request public-api Affects public API
Projects
None yet
Development

No branches or pull requests

3 participants