‘NSInternalInconsistencyException’ when running UITesting with Xcode 7

梦想与她 提交于 2019-12-03 04:15: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"

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.

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.

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.

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.

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

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.

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".

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

continueAfterFailure = false & XCUIApplication().launch()

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.

  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。
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!