XCTest in xcode 5--tests fail without any issue generated
This is a bug in Xcode and is corrected in version 5.1 . When using the simulator, tests can sometimes show the message Test target [test name] encountered an error (Test process exited with code -1)
See Xcode release notes for official details:
enter link description here
Compile errors don't show up when using XCTest with swift
I was facing the same issue. What fixed the problem on my side was to make sure that my Schema included "Analize" or "Test" for the UI Test Target. Like so:
Only then warnings and errors messages started popping up in my UI test classes:
No such module when using @testable in Xcode Unit tests
The answer that worked for me
The answer was that I had some errors in my project that was making the build fail. (It was just your standard every day bug in the code.) After I fixed the errors and did another clean and build, it worked.
Note that these errors didn't show up at first. To get them to show up:
- Comment out your entire Test file that is giving you the "No such module" error.
- Try to run your project again.
If there are other errors, they should show up now. Fix them and then uncomment your Test file code. The "No such module" error was gone for me.
In case this doesn't solve the problem for other people, you can also try the following:
Clean the build folder
Open the Product menu, hold down Option, and click "Clean Build Folder..."
Make sure that Enable Testability is set to Yes
In the Project Navigator click your project name. Select Build Settings and scroll down to Build Options. Make sure that Enable Testability is Yes (for debug).
Delete and re-add your Tests target
If you have done the other things my guess is that you probably don't need to do this. But if you do, remember to save any Unit Tests that you have already written.
Click your project name in the Project Navigator. Then select your Tests target. Click the minus (-) button at the bottom to delete it.
Then click the plus (+) button and choose iOS Unit Testing Bundle to add it back again. As you can see, you can also add a UI Testing Bundle in the same way.
A few other ideas
- Make sure that all required classes are members of your test target.
- Make sure that you have added all the required libraries.
- Make sure that the module name is written correctly (see this answer).
Or...
Leave a comment or answer below if you found something else that worked.
Related
- How to do a Unit Test in Xcode
- Xcode UI Test example
Xcode 5 throws Library not loaded error when adding a test target
You must run your test on the iOS 7 simulator. It will not work on iOS 6.x.
Xcode 5: Unit Tests not running
Xcode 5 now used XCTestCase, not SenTest. Apple is now supporting Unit Testing more directly including their own version of SenTest named XCTestCase. Additionally the UI is much improved, allowing individual tests to be run, a Test Navigator and no longer creating .h test files. Note that the test macros are not renames with an XC prefix.
See the WWDC-13 video 409: "Testing in Xcode 5".
If you use the Xcode 5 template to create the testing environment the project will include a test target and a working (and failing) test.
Xcode 5 - -bundle_loader can only be used with -bundle XCTest
The Mach-O Linker flag in the test target was set to "executable" instead of "bundle".
Xcode 5 -- Test target did not finish
Without receiving a better answer after a couple weeks, I'm going to answer my own question with the solution that seems to have worked for me.
A simple uninstall/reinstall from the simulator seems to fix the problem, though I've yet to determine what causes it, or why this fixes it.
Related Topics
Is -[Uitableview Reloaddata] Asynchronous or Synchronous
Avcapturevideopreviewlayer Landscape Orientation
How to Run Xctest Tests in an iOS App
How to Disable Arc for a Single File in Xcode 5
How to Get Change in Network Connection Notification from iOS Reachability Class
Can't Set Background Color of Uitableviewcell in Ib
Uitextfield Not Getting Keyboard Input
Fcm Notification in iOS Doesn't Play Sound When Received
How to Add a Credit/Debit Card into Apple Wallet from the iOS App
How to Change Space Between Cells in Uicollectionview
Autosizing Cells: Cell Width Equal to the Collectionview
Swift Base64 Decoding Returns Nil
Link to Safari "Add to Home Screen" from Inside App
How to Check If the iOS Device Is Locked/Unlocked Using Swift
Dynamic Uicollectionview Header Size Based on Uilabel
Change Uifont in Secure Uitextfield Strange Behaviour in iOS7