‘NSInternalInconsistencyException’ when running UITesting with Xcode 7

20,562

Solution 1

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

Solution 2

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"

Solution 3

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

Solution 4

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.

Solution 5

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.

Share:
20,562
SuPotter
Author by

SuPotter

Updated on July 09, 2022

Comments

  • SuPotter
    SuPotter almost 2 years

    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

  • SuPotter
    SuPotter over 8 years
    Yes, I saw that post. I had the correct target to start with. thanks
  • DonnaLea
    DonnaLea over 8 years
    Doing this does not fix the issue for me :(
  • Dallas
    Dallas almost 8 years
    Aha! This answer is really helpful, this is one of those cases where you could look all day and find no fix because just by looking at the file there is no showing that anything is wrong.
  • Kris
    Kris almost 8 years
    Thanks a lot! I got the same problem after renaming whole project.
  • Jeroen Bakker
    Jeroen Bakker almost 8 years
    I had to set the 'Target Application' to 'None' and hit build. Then I had to set the 'Target Application't back to my project. Thx!
  • Leo
    Leo over 7 years
    This saved my day. The tests daemon on the device seems not very stable.
  • Laser Hawk
    Laser Hawk about 7 years
    @Leo indeed the daemon is unresponsive. I even tried popping the cache on the phone without a restart and that didn't resolve it. Restarting worked for me, silly but effective fix. Thanks.
  • DevAndArtist
    DevAndArtist about 7 years
    I literally bumped into the same issue. Comparing the templates was a good hint. Thank you.
  • Hola Soy Edu Feliz Navidad
    Hola Soy Edu Feliz Navidad over 6 years
    I'd downvote here, however as I lose score for doing it I won't do it. This is not the answer.
  • Neal.Marlin
    Neal.Marlin about 6 years
    You save my ass! thks!
  • Alex Zavatone
    Alex Zavatone over 5 years
    I wish this worked for me. I've tried both and still get the same issue with UIApplication.
  • Alex Zavatone
    Alex Zavatone over 5 years
    That's the wrong answer. It should be "iOS UI Testing Bundle"
  • arango_86
    arango_86 over 5 years
    modified. Bulls eye. :)