-
Notifications
You must be signed in to change notification settings - Fork 268
Description
Hello!
I'm maintainer of Nimble, a framework that provides an alternative assertion DSL for Swift and Objective-C. Earlier today, I noticed that Nimble's integration with XCTest on Linux & Windows is lacking, which is entirely because there isn't a good place for Nimble to register its XCTestObservation conformer - which is how Nimble currently keeps track of the current test case - in a non-objc environment. On Darwin platforms, Nimble registers its XCTestObservation conformer when it's loaded, but that only works when the objc runtime is available.
Naively, I would think that making XCTCurrentTestCase publicly readable would solve this issue for Nimble, such as this patch:
diff --git a/Sources/XCTest/Public/XCTestCase.swift b/Sources/XCTest/Public/XCTestCase.swift
index 2d899b9..6e229fe 100644
--- a/Sources/XCTest/Public/XCTestCase.swift
+++ b/Sources/XCTest/Public/XCTestCase.swift
@@ -25,7 +25,7 @@ public typealias XCTestCaseEntry = (testCaseClass: XCTestCase.Type, allTests: [(
// A global pointer to the currently running test case. This is required in
// order for XCTAssert functions to report failures.
-internal var XCTCurrentTestCase: XCTestCase?
+public private(set) var XCTCurrentTestCase: XCTestCase?
/// An instance of this class represents an individual test case which can be
/// run by the framework. This class is normally subclassed and extended withWhich would work, but I'm curious if that's actually the right approach that should be used here. There's probably a very good reason you haven't made XCTCurrentTestCase publicly readable, after all.