Avatar
@swift-6.2 + testing import Testing struct MyRecursiveSuiteTrait: SuiteTrait & TestTrait & TestScoping { var isRecursive: Bool { true } func provideScope( for test: Test, testCase: Test.Case?, performing function: () async throws -> Void ) async throws { print("enter provideScope", test.name, testCase == nil ? "suite" : "test") defer { print("leave provideScope", test.name, testCase == nil ? "suite" : "test") } try await function() } } extension Trait where Self == MyRecursiveSuiteTrait { static var mySuperSuite: Self { Self() } } // a. ここで Suite trait として1回呼ばれる @Suite(.mySuperSuite) struct MyTest { // b. ここで Suite trait として1回呼ばれる // c. ここで Test trait として1回呼ばれる @Test func foo() { print("foo") } // d. ここで Suite trait として1回呼ばれる // e. ここで Test trait として1回呼ばれる @Test func bar() { print("bar") } }