Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import XCTest in to existing project

I added a new target as a Cocoa Touch Unit Testing Bundle, named the directory "MyAppTests", and the actual framework is not active-- it is highlighted red

enter image description here

When I add the framework by the 'link binary with libraries' in the 'build phases' tab technique, a new Framework is added, instead of updating the one that was created with adding the target.

enter image description here

When I go to run the code, I then run in to all sorts of troubles, ranging from linking errors to other frameworks not being recognized.

How can I activate the XCTest.framework that was generated when I added target? Please help, thank you!

like image 740
aug2uag Avatar asked Oct 07 '13 16:10

aug2uag


People also ask

How do I add an XCTest to an existing project?

If you have an existing project and you want to start adding Unit test. Do the following. Go to File > New > Target and select Unit Testing Bundle and hit Next then Finish. Repeat same steps this time select UI Unit Testing Bundle.

How do I add unit tests to an existing Xcode project?

To add a unit test target to an existing Xcode project, choose File > New > Target. Select your app platform (iOS, macOS, watchOS, tvOS) from the top of the New Target Assistant. Select the Unit Testing Bundle target from the list of targets.

How do I run XCTest in Xcode?

To run your app's XCTests on Test Lab devices, build it for testing on a Generic iOS Device: From the device dropdown at the top of your Xcode workspace window, select Generic iOS Device. In the macOS menu bar, select Product > Build For > Testing.

What is XCTest in iOS?

Overview. Use the XCTest framework to write unit tests for your Xcode projects that integrate seamlessly with Xcode's testing workflow. Tests assert that certain conditions are satisfied during code execution, and record test failures (with optional messages) if those conditions aren't satisfied.


1 Answers

XCTest.framework is the bundle that Xcode uses to enable

#import <XCTest/XCTest.h>

To add test cases to an existing project select the target, right click > file > new > objective c test case class. Then in your build phases you can add the XCTest.Framework. Make sure you check the add to target boxes when creating the test case.

like image 110
JuJoDi Avatar answered Oct 21 '22 19:10

JuJoDi