Skip to content

Recursive Suite Traits must conform to TestTrait or else they crash #1048

Open
@KentLottis-jwn

Description

@KentLottis-jwn

Description

If a recursive SuiteTrait type fails to also conform to TestSuite, you get a runtime crash (apparently an assertion failure)

See this Swift.org discussion

Reproduction

// DANGER: missing TestSuite conformance
struct TestConfiguration: SuiteTrait, TestScoping {
    let isRecursive: Bool = true
    func provideScope(for test: Test, testCase: Test.Case?, performing function: @Sendable () async throws -> Void) async throws {
        try await function()
    }
}

extension Trait where Self == TestConfiguration {
    static var testConfiguration: Self { Self() }
}

@Suite(.testConfiguration)
struct DemoSuite {
    @Test func demo1() {}

Expected behavior

Ideally, some sort of catastrophic but non-crashing result. Or, at least, a clearer indication as to what's wrong

Environment

Xcode 16.3

Testing Library Version: 124

Additional information

No response

Metadata

Metadata

Assignees

Labels

bug🪲 Something isn't workingtraitsIssues and PRs related to the trait subsystem or built-in traits

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions