IOS Unit Test

Source: Internet
Author: User

This article reprinted to http://blog.csdn.net/fengsh998/article/details/8109293IOS comes with unit tests.

1. When created, include the Unit tests hook.

This creates a test project that automatically generates a tests knot. Open PROJECTTEST.M to see a test method that the system has created good one test examples testexample

You can now run the test unit to see the effect.

Click Run, press and hold the pop-up test, select test

The running result is of course a test method, because there is a self-contained demo code.

Here, the test unit project is ready to work.

Write a test method below to try it out.

The newly created test class must be sentestcase as the base class.

The test method name must be prefixed with test.

-(void) Testisok

{

NSLog (@ "Call here");

}

Refer to the. h text when testing a class method in a test project. You can test the corresponding method by creating the corresponding instance object.

2, in the existing projects to create test engineering.

Click File--new--new Target

In the pop-up selection box Ios-->other---> Cocoa Touch Unit testing Bundle

Click Next to enter the project name.

Click Done.

A test project will be generated.

It seems ok here, but still a step, after clicking on Run, the long press to produce test, click Test to open the test, will produce a hint: the scheme "project name" is not a configured for testing. Edit the scheme to enable Testing,or cancel the action.

That is, we have not yet configured a test project line for the project, click Edit to add it, or click Cancel to finish.

Click on Edit scheme (or Producu->edit scheme in the menu)

Pop up the scheme form. Check test and click on the + sign to add a scheme

Select the previously created Coredatademotest and click Add

Add post effect.

Click OK to run the test project.

The run section is shown in the previous Run Test Unit section.

To this, iOS comes with a test unit complete, for third-party ghunit and Ocmock see:

Articles in the http://www.uml.org.cn/mobiledev/201201093.asp

IOS Unit Test

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.