Khant Thu Linn
Khant Thu Linn

Reputation: 6143

_XCTFailInCurrentTest should only be called while a test is running

I am now doing for UITesting with Xcode and I got this error.

* Assertion failure in void _XCTFailInCurrentTest(NSString *, ...)(), /Library/Caches/com.apple.xbs/Sources/XCTest_Sim/XCTest-10112/XCTestFramework/Classes/XCTestCase.m:63 2016-05-13 22:31:54.961 XCTRunner[15428:168507] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '_XCTFailInCurrentTest should only be called while a test is running. Failure description: Failed to receive completion for

I have seen other similar post here.

Cannot run Xcode (7.3) UI tests in Jenkins

I am using Jenkins but for now, I am directly running from Xcode and I can't even run from Xcode. How shall I do?

Upvotes: 4

Views: 529

Answers (3)

Webdevotion
Webdevotion

Reputation: 1243

We tried the tips from the other responses, which did not work for us.
A complete reinstall of Xcode 7.3 fixed our issue.

  • remove Xcode
  • restart
  • reinstall Xcode
  • success

Upvotes: 0

By some reason simulator got corrupted. In my case it was not possible to launch any test once get at the same point. In my case what it worked was reset simulator (Menu Simulator|Reset Contents and Settings...) or switch to any other simulator.

Upvotes: 0

Vish
Vish

Reputation: 2174

Background

  • I faced this issue in Xcode 7.3 (7D175) and iOS Simulator 9.3.
  • The symptoms were as follows
    • the Test Runner launches normally and exits.
    • Following this, the app under test never launches.
    • (if the app under test was not installed, Xcode will also never install the app prior to starting the test).
    • (a side symptom is that recording also does not work for me - I took inspiration from this SO post.)

After 30 seconds the test times out with:

XCTRunner[36260:489138] Continuing to run tests in the background with task ID 1    
2016-05-18 16:17:25.720 XCTRunner[36260:489138] *** Assertion failure in void _XCTFailInCurrentTest(NSString *, ...)(), /Library/Caches/com.apple.xbs/Sources/XCTest_Sim/XCTest-10112/XCTestFramework/Classes/XCTestCase.m:63
2016-05-18 16:17:25.723 XCTRunner[36260:489138] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '_XCTFailInCurrentTest should only be called while a test is running.
Failure description: Failed to receive completion for <XCDeviceEvent:0x7fddc241f970 page 12 usage 64 duration 0.01s within 30.0s'

The fix that worked for me was:

  • reset the simulator.
  • check whether the deployment target is set to iOS 9.x in the build settings for the UI Test Target. (in my case it was set to iOS 8)
  • after changing the target, clean and rebuild.

After following these steps, Xcode was able to install the app prior to the test, recording worked, and the error went away.

Upvotes: 4

Related Questions