‘NSInternalInconsistencyException’ when running UI

2019-03-17 05:57发布

Ok, I’ve not been able to run this test in any betas so far. Some of the issues I’ve encountered are here and here

Now, I feel like I’m missing something.

Here’s my progress so far

  1. Enabled “UI testing” option while creating a new project. This, in fact adds a target for me. So I should be good to go - or so I thought. enter image description here
  2. The swift file under UI Testing had already “XCTest” imported and was a subclass of “XCTestCase”.
  3. setup() launches the application XCUIApplication().launch()
  4. And I added the following (by hitting the Record button) enter image description here

And then, I ran this test.

The whole thing fails even before the test is called, right after launching app in setup() with the following

*** Assertion failure in -[XCUIApplication init], /Library/Caches/com.apple.xbs/Sources/XCTest_Sim/XCTest-8170.3/XCTestFramework/UI Testing/XCUIApplication.m:76 /Users/UserName/Documents/Projects/Testing/UiTesting/UITestingApp/UITestingApp.swift:0: error: -[UITestingApp.UITestingApp testSimpleTap] : failed: caught "NSInternalInconsistencyException", "No target application path specified via test configuration:
testBundleURL:file:///Users/UserName/Library/Developer/CoreSimulator/Devices/E3201DC2-CAD3-48C3-95F5-15E18DCA1836/data/Containers/Bundle/Application/8B33FC59-FC03-41F8-BD21-43D81BA2D355/UITestingApp-Runner.app/PlugIns/UITestingApp.xctest/
productModuleName:(null) testsToSkip:(null) testsToRun:(null) reportResultsToIDE:no sessionIdentifier:<__NSConcreteUUID 0x7f93e146c0b0> F242796B-ED26-4AA7-861A-540D2D93CB8F pathToXcodeReportingSocket:(null) disablePerformanceMetrics:no treatMissingBaselinesAsFailures:no baselineFileURL:(null) targetApplicationPath:(null) targetApplicationBundleID:(null) reportActivities:no

Anyone run into this or has any suggestions on what I might be missing?

Note: I did set the “Target Application” of the UI Testing target to my app

Update: I noticed this is applicable to all beta/final releases of Xcode - updated title accordingly

11条回答
家丑人穷心不美
2楼-- · 2019-03-17 06:07

I had this issue running Cucumberish tests on xCode 8.

I fixed by going Project ( In project navigator ) > MyTestTarget > General

Here make sure that the Target Application is set to the application you wish to run the tests against. By Default it was set to None.

查看更多
Root(大扎)
3楼-- · 2019-03-17 06:08

Deleting the existing Target and creating again fixes the problem.

Make sure that you are selecting the right test bundle. For UI testing it should be "iOS UI Testing Bundle".

查看更多
我只想做你的唯一
4楼-- · 2019-03-17 06:13

This happened to me when I was trying to add a new class to my unit test target but I've selected UI Test Case Class template instead of Unit Test Case Class template.

Make sure that you always select proper one. Eventhough they are both XCTestCase subclass and you assign them to proper target, it will throw this error when selecting wrong template.

enter image description here

查看更多
干净又极端
5楼-- · 2019-03-17 06:15

I had this exact problem. I think the issue stemmed from renaming a target along the way. None of the fixes here helped me with my issue. Since I was just getting started and hadn't written any tests yet I deleted the entire target for the UI tests and re-added it. Same name and everything started working just fine.

If you run into this issue, its possible it is due to the naming. You can track it down that way or save your tests and re-add a UI target.

查看更多
老娘就宠你
6楼-- · 2019-03-17 06:15

It worked for me after I Comment the below code in setup() method of my TestCaseClass

continueAfterFailure = false & XCUIApplication().launch()

查看更多
ゆ 、 Hurt°
7楼-- · 2019-03-17 06:18

I am getting the assertion

*** Assertion failure in -[XCUIApplication init], /Library/Caches/com.apple.xbs/Sources/XCTest_Sim/XCTest-8170.3/XCTestFramework/UI Testing/XCUIApplication.m:76

regularly, just as also described in other answers. Really annoying, and it took me some time to find the minimum steps to get rid of it.

The key solution I have found is to reboot your device. So, you don't need to remove the app, restart Xcode or something, just rebooting should make this assertion disappear.

查看更多
登录 后发表回答