‘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:19

After endless tweaking, changed the Location of Derived Data in "Xcode Preferences" from "Legacy" to "Custom" and got it to work!

enter image description here

查看更多
Juvenile、少年°
3楼-- · 2019-03-17 06:21

I had a similar issue and my mistake was trying to use UI testing code in a regular test target. Once I made a new target, starting with "iOS UI Testing Bundle" and copied the code there the error went away. Here's the thread that pointed me in the right direction: https://twitter.com/punksomething/status/609505357132500993 "Yeah, I was trying to use a UI test in a regular test target. Had to create a newly added UI Test target"

查看更多
萌系小妹纸
4楼-- · 2019-03-17 06:22

I was getting this error after writing a few tests and running them. I tried all the fixes and suggestions posted but none of them worked for me.

I decided to delete the XCUI app that gets created whenever you run tests and restart my device and it worked. however if i run the tests 7 or 8 times afterwards, the error comes back and i just repeat the solution cycle. If you just delete the app and don't restart it won't work.

Not sure if this answer will work for everyone but this is what worked for me.

查看更多
兄弟一词,经得起流年.
5楼-- · 2019-03-17 06:24
  1. New create file UI Test Case and Unit Test Case templates are not much different , ( The former two lines of code ),Select Unit Test in the test will prompt "Application is not running",Adding "XCUIApplication().launch()" can solve the problem。
  2. When the test prompted not to find a control (E.g UITextField),Please set the control name \ identity -> accessibility -> Label \ to the same name as the control used in the UITestClass。
  3. You did not add the test class to the corresponding UI Targets。
查看更多
我想做一个坏孩纸
6楼-- · 2019-03-17 06:31

I got this after renaming my target. The solution was to set the 'Target Application' to 'None' in my UITest target and hit build. After this I set 'None' back my app and the error resolved. I think it's highly possible that the renaming messed up the ui test target's 'Target Application' settings.

查看更多
登录 后发表回答