Objective-C Warning RunUnitTests is obsolete. Xcode 7 - ios

I am getting this warning in Objective-C:
RunUnitTests is obsolete. To run unit tests for your target, use the Test scheme action in the Xcode IDE and the test action in xcodebuild.
I did some googling around and found a solution to add TEST_AFTER_BUILD and set it to YES in User-Defined settings. After doing this the warning is still there. What am I doing wrong?

You need to delete the Run Script build phase that invokes RunUnitTests from your unit test bundle target, as suggested by the Xcode info message when it tries to build your unit test bundle.
This is the offending Run Script build phase, likely stuck there by a previous version of Xcode:

Related

Xcode unit test shows 'No such module <project name>' but it can run?

I create an application with multiple build config, bundle id, and product name. I can run the unit test but in the unit test code, there is an error shows No such module 'ProjectName' like in the picture below. Still, it can run the unit test and the test is passed as well. It can't use the auto complete, though.
I have cleaned the build folder and restart the Xcode but it's not work.
I don't know what's going on. Could someone give me some workaround?
Update
I found the solution. Just change the build scheme in Use [build scheme] for command-line builds to your unit test build scheme test target at the project level on info tab. Then everything works fine.
just try to clean and restart Xcode it will work properly
Delete derived data https://programmingwithswift.com/delete-derived-data-xcode/
Clean the project with cmd + k
Build and re-run the unit tests with cmd + u
I found the solution. Just change the build scheme in Use [build scheme] for command-line builds to your unit test build scheme test target at the project level on info tab. Then everything works fine.

Can't run unit tests in Xcode 8 with earlier unit test configuration

I ran into this issue after upgrading to Xcode 8. When running the tests I get this error at run time:
/Users/<me>/work/<appname>/Build/Intermediates/<appname>.build/Debug-iphonesimulator/<appname>UnitTests.build/Script-231C35D610AC1F5000D830C2.sh: line 3: /Applications/Xcode.app/Contents/Developer/Tools/RunUnitTests: No such file or directory
The sh script in the error message is trying to access the RunUnitTests tool and fails. I assume this tool has been removed in Xcode 8. It seems that for my project Xcode tries to run tests in a way that is no longer supported. If I create a brand new project no such script is created and I can run tests.
Any idea what settings I need to update in my project to get the tests running again? I tried the 'Update to recommended settings' checklist but it doesn't solve this issue.
It seems I only needed to remove the Run Script phase that invoked that script.
Removing Run Script from the Build Phases didn't help me.
I simply copied /Applications/Xcode.app/Contents/Developer/Tools/RunUnitTests from my older Xcode into my XCode 8 package content. Give it right permissions:
RWXR-XR-X
And it worked for me.

Xcode: Adding a Test that fails when there are Static Analyzer warnings or errors?

I want my Xcode project's tests to fail when there are analyzer warnings or errors.
Running the Xcode "Analyze" command points out the analyzer errors in your project:
However, when I use Xcode's "Test" command on this same target I'm all green:
Is there a way to add a "Run Static Analyzer" test or build phase to the testing target? We are using XCTest. I find myself sometimes testing the target and thinking things are fine, only to have forgotten to fix a simple memory issue.
Our tests should fail when there are analyzer warnings or errors.
You can set it to analyze during build in the build settings (just search for analyze). Set "Analyze during 'Build'" to YES.

Xcode 5: Unit Tests not running

I created a few test cases and they all passed... That's because they are not being run.
From Xcode, I get:
Test Suite 'All tests' started at...
Test Suite 'All tests' finished at...
Executed 0 tests, with 0 failures (0 unexpected) in 0.00 seconds
The project (and unit test classes) build successfully.
All my test classes have MyApp_appTests as Target Membership selected. Production classes have MyApp_app & MyApp_appTests targets selected.
I verified the MyApp_appTests Target Build Settings (Bundle Loader & Test Host).
Bundle Loader (Debug): $(BUILT_PRODUCTS_DIR)/MyApp.app/MyApp
Test Host (Debug): $(BUNDLE_LOADER)
I have imported SenTestingKit.framework (through Targets Build Phases "Link Binary With Libraries").
All my tests start with -(void)testThat...
I have also checked a few stackoverflow.com questions:
stackoverflow.com/questions/8632254/xcode-4-2-cant-run-unit-test
stackoverflow.com/questions/3608484/ocunit-tests-not-running-not-being-found
stackoverflow.com/questions/16672616/ocunit-test-cases-not-running
and this post:
twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/
I don't know where to look for... Any help is greatly appreciated!
For me worked changing "Wrapper extension" from "octest" to "xctest" in Build Settings for tests target
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.
If you are creating a new test target in Xcode 5+ and planning to use SenTestKit for unit tests, changing the 'Wrapper Extension' build setting of your test target to 'octest' from the default 'xctest' will help execute the test cases.
I had this problem with Xcode 7.3, what worked for me was running the application on the device once and then running the tests.

Build error on Zapp when running iPhone app (with KIF testsuites)

I am working on a sample project for testing KIF framework and Zapp. The project (with Directory scheme and Integration Tests scheme) builds fine on XCode and runs on Simulator.
The GitHub url for the project is here: https://github.com/dolphyfernandes/DirectoryApp
I am trying to run Zapp for continuous Integration (CI). The project when run via Zapp with Directory scheme runs fine. But when I update the scheme drop-down to Integration Tests, the build fails.
Below is the error log on the Zapp
ld: library not found for -lKIF
Command /Developer/Platforms/iPhoneSimulator.platoform/Developer/usr/bin/clang failed with exit code 1
** BUILD FAILED **
The following build commands failed:
LD "build/Applications/Directory (Integration Tests).app/Directory (Integration Tests)" normal i386
(1 failure)
Could anyone help me out with this issue? It seems like everything should work fine.
Thanks.
I found the solution to the problem.
I had posted the same question on google groups and I got some help over there. The documentation for KIF setup doesn't directly work with Zapp.
https://groups.google.com/d/msg/kif-framework/biRg1-W1O70/vGYWlyAilsEJ
The solution for Zapp to work with KIF is that Zapp project requires to have libKIF.a as a Target Dependency to your app's test target.
You could do the following:
Step 1: Drag KIF project under your main project, nested as shown.
- - - - - ->
Step 2: Click on edit Scheme on top left of XCode and add KIF target to the Build of Test scheme as shown.
Step 3: Add KIF to Target Dependencies by selecting test target > Build Phases and clicking on Add button to add KIF.
This should work fine with Zapp and it now works without any build errors.
Feel free to add to the thread in case of any questions!
#leonardoborges .. I was waiting for you :)
I had prepared this pdf just in case someone would need it. The PDF has detailed step-by-step instructions and hopefully doesn't miss anything.
Have a look at it and let me know if you would need any more information.
http://www.files.com/set/50e715498087f
Thanks!

Resources