diff --git a/Sources/XCTestDynamicOverlay/XCTIsTesting.swift b/Sources/XCTestDynamicOverlay/XCTIsTesting.swift index c777b8ac..86a0df2e 100644 --- a/Sources/XCTestDynamicOverlay/XCTIsTesting.swift +++ b/Sources/XCTestDynamicOverlay/XCTIsTesting.swift @@ -1,9 +1,9 @@ import Foundation public let _XCTIsTesting: Bool = { - guard let path = ProcessInfo.processInfo.arguments.first - else { return false } - - let url = URL(fileURLWithPath: path) - return url.lastPathComponent == "xctest" || url.pathExtension == "xctest" + ProcessInfo.processInfo.environment.keys.contains("XCTestSessionIdentifier") + || ProcessInfo.processInfo.arguments.first + .flatMap(URL.init(fileURLWithPath:)) + .map { $0.lastPathComponent == "xctest" || $0.pathExtension == "xctest" } + ?? false }()