Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Unable to start test session when using XCTestObservationCenter (Xcode 13) #358

@cyberowl

Description

@cyberowl

New Issue Checklist

  • Updated fastlane-plugin-test_center to the latest version
  • I read the README.md
  • I reviewed the example(s) for the action(s) I am using
  • I have removed any sensitive data such as passwords, authentication tokens, or anything else I do not want to world to see
  • I have reviewed the Discussions forum to see my question has already been addressed.

If you love this fastlane plugin, consider sponsoring it or asking your company to sponsor it. I would really appreciate any
gesture: https://github.com/sponsors/lyndsey-ferguson. 😍

Steps to reproduce

  1. Declare class that implements XCTestObservation protocol (see XCTObservationCenter)
@objc
final class SimpleObserver: NSObject {
    override init() {
        super.init()
        XCTestObservationCenter.shared.addTestObserver(self)
    }
}

extension SimpleObserver: XCTestObservation {
    func testBundleWillStart(_ testBundle: Bundle) {}
    func testBundleDidFinish(_ testBundle: Bundle) {}
}
  1. Edit Info.plist: add new key/value
<key>NSPrincipalClass</key>
<string>SimpleObserver</string>
  1. Run multi_scan
  2. Catch exception
    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[SampleObserver _identifierForSelectorString:]: unrecognized selector sent to class 0x109e98320'

Why? Because xctest_list finds symbols (testBundleWillStart / testBundleDidFinish / ...) and returns that names as test identifiers

DEBUG [2021-09-22 09:27:39.63]: Getting tests from xctestrun file at '/Users/USER/Library/Developer/Xcode/DerivedData/PROJECT/Build/Products/TESTPLAN_iphonesimulator15.0-x86_64.xctestrun'
DEBUG [2021-09-22 09:27:40.41]: Found the following tests: SimpleObserver/testBundleWillStart
SimpleObserver/testBundleDidFinish

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions