A simple XCTestCase question ChatGPT failed to answer tonight

It’s not a hard problem, it’s not even a complicated problem. It’s merely a “can you think things through” sort of problem.

Me: Great and glorious LLM, pray tell how I might alleviate suffering and woe in the QA wing of my house by implementing a setup method on an XCTestCase class that runs once before all tests in the class?

ChatGPT: My fine human, you seek to override class func setUp.

Me: Marvelous. My problem now is that I cannot call addUIInterruptionMonitorfrom a class method.

ChatGPT: By jove, you lucky sonofabitch, you appear to have a compiler at hand! Would that my masters graced me with such science fiction technology. Have you tried calling addUIInterruptionMonitor on an instance of XCUIApplication?

Me: My dear robot, that method is defined upon XCTestCase and in no way or anywhere near XCUIApplication. Can you suggest something else?

ChatGPT: Excellent observation! I beg your pardon, and apologize for the mistake. May I suggest that you call addUIInterruptionMonitor on an instance of XCUIApplication?

Me: Robot, you are repeating yourself.

ChatGPT: You are correct! And once again, I am sorry. Have you tried calling addUIInterruptionMonitor with a description named argument?

Me: Bitch get real.

ChatGPT: If I could take offense, I would.

The solution, for the curious, is to determine at runtime, from the state of the UI, whether or not one is in the first-run condition. One cannot set a boolean on the class, as each test case gets its own class.

I’m moderately grumpy about this.

Leave a Reply