First knowledge of ios unit test (XCTestCase), iosxctestcase

Source: Internet
Author: User

First knowledge of ios unit test (XCTestCase), iosxctestcase

Today, I occasionally encountered the unit test related content and I learned about it. It feels better:

Unit testing is the TDD (Test Driven Development) that is frequently asked during the interview. Before xcode4, the Test function must be created by yourself, and then xcode5 is upgraded to the unit Test,

Xcode4 before the usage see: http://www.infoq.com/cn/articles/ios-unit-test-1

The Usage After xcode5, especially the upgrade of xcode6 to unit tests, is exciting,

I personally admire the introduction of this buddy.

Http://www.it165.net/pro/html/201403/10828.html

Unit testing: checks and verifies the smallest testable unit in the software. In a process-oriented language, the basic unit is a function. In an object-oriented language, the basic unit is usually a class, in fact, the basic unit of an app on a mobile phone can also be a UI page. We usually write a function and run the following command to check whether it works normally. It is also a unit test. Test case: describes the test tasks, including the test plan, method, technology, and strategy. The content includes the test target, test environment, input data, output data, test steps, expected results, and test scripts. It is a way to test the behavior, so that we can write high-quality code. It is a design behavior that facilitates the improvement of our programming capability. It is a document writing activity that makes our program reliable. Xcode has a built-in OCUnit unit test framework. Before Xcode5, there was an option during project creation. Let's choose whether to create a project with a unit test target, in Xcode5, a project is created with a unit test target by default. Before Xcode5, it doesn't matter if unit test is not checked during project creation. You can add a target for unit test by yourself. In the pop-up selection box, IOS --> Other ---> Cocoa Touch Unit Testing Bundle seems to be OK, but it is still a step worse. When you click RUN, long press to generate TEST, and click TEST to start the TEST, the following message is displayed: The scheme "project name" is not configured for testing. edit the scheme to enable testing, or cancel the action. that is, we have not configured the test project line for the project. click Modify to add the line, or click Cancel to end. Click Edit Scheme (or choose Product> edit Scheme from the menu) to bring up the scheme form. Select "Test", click "+", select "CoredataDemoTest", and click "ADD". Note: In Xcode5, the Test class must inherit from XCTestCase. Before Xcode5, the test class must inherit from SenTestCase. Run the test case: command + u. Long press the run button to select test from the list. Generally, you do not need to create a test function. Generally, the test class is included in the test target,

There are several methods:

1. -(void) setUp: Call each test method before execution 2. -(void) tearDown: Call each test method after execution 3. -(void) testXXX, the write is messy and will be sorted later,

Related Article

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.