Skip to content

Commit

Permalink
Only register suites that contain EmbeddedTestCase tests. (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
samdeane authored Dec 19, 2024
1 parent 23c329a commit 457a15c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@

import XCTest

/// Non-generic base class for EmbeddedTestCase.
open class EmbeddedTestBase: XCTestCase {
}

/// Superclass for test cases that are embedded.
///
/// When running normally, the tests will be silent and will do nothing.
/// When re-run the embedded context, the test case will perform its normal
/// actions.
open class EmbeddedTestCase<T: TestHost>: XCTestCase {
open class EmbeddedTestCase<T: TestHost>: EmbeddedTestBase {
override open var name: String {
return EmbeddingController.isRunningEmbedded ? "Embedded(\(super.name))" : super.name
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class EmbeddingController: NSObject, XCTestObservation {
/// Record a test suite that has finished running.
func registerSuite(_ suite: XCTestSuite) {
if !isRunningEmbedded {
if let test = suite.tests.first as? XCTestCase {
if let test = suite.tests.first as? EmbeddedTestBase {
let testClass = type(of: test)
let injected = EmbeddedTestCaseSuite(for: testClass, tests: suite.tests)
embeddedSuite.addTest(injected)
Expand Down Expand Up @@ -107,8 +107,6 @@ public class EmbeddingController: NSObject, XCTestObservation {
public func testSuiteDidFinish(_ testSuite: XCTestSuite) {
if testSuite.className == "XCTestCaseSuite" {
registerSuite(testSuite)
// } else {
// print("SKIPPED \(testSuite) \(type(of: testSuite))")
}
}

Expand Down

0 comments on commit 457a15c

Please sign in to comment.