IPhone/iPad unit test in xcode 4.3

Source: Internet
Author: User

When you create a new project, you can see a unit test. Just try it. Let's just do it. Today we have created a new testapp. In fact, you can directly select include unit test, but I do not select this option.

Click to enter the project. The project and target options are displayed. Click Add target directly. You can also select a new target from the File menu. Select cocoa touch unit testing bundle in other of iOS, create a new testapptests, and finish. A new target is created in the target project. The testapptests folder is displayed in the project, there are h and M files with the same name below. All functions created in M files whose names start with test will automatically run.

1. Select testapptests. First, selectBuild phasesUnderTarget Dependencies, Add testapptests as the target dependency.

2. In the build setting option, double-click the bundle loader and set the value to $ (built_products_dir)/testapptests. APP/testapptests.

3. Search againTest hostAnd set the value to $ (bundle_loader ).

4. Click the target of the application, that is, the target of your project testapp.Symbols hidden by defaultIs no.

5. at this time, the test button in the menu product is gray. If we want to test the program before running it, edit scheme is required. You can enter it from the menu project, you can also click scheme in the toolbar, select Edit scheme, select target: testapp to be set, and click the test option on the left to see the +-number at the bottom of the right? Click "+", select the target for test, and press "OK. After this step, you can see the optional test button in the menu product. Click test and test scceeded will appear.

6. view show the log navigator and click testapptests. In the content on the right, a button appears at the bottom right of the dimmed entry when you move the cursor over the entry, click "button" to view the unit test result. You can also view it in the unit test file by hitting a breakpoint.

If Step 2 is not performed ~ 4. the following error occurs when you click test:

Undefined symbols for architecture i386:  "_OBJC_CLASS_$_TestAppTests", referenced from:      objc-class-ref in TestAppTests.o

References:

Http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.