Today, occasionally encountered the unit test related content, I learned about it, feel more useful:
Unit testing is often asked in the interview TDD (TestDriven development), XCODE4 before the test function to create their own, then XCODE5, the unit test was upgraded,
Xcode4 the previous usage see: http://www.infoq.com/cn/articles/ios-unit-test-1
The usage after XCODE5, especially the xcode6 of the unit test, is quite exciting,
Personal comparison admire the following this buddy's introduction, more detailed
Http://www.it165.net/pro/html/201403/10828.html
Unit Test(Unit Testing): Checks and verifies the smallest testable unit in the software. In the general process-oriented language, the basic unit is a function, and the basic unit is usually a class in object-oriented language, in fact, for aMobile PhoneThe basic unit can also be a UI page on the app. Usually we write a function that performs the following to see if it is normalwork, which is also part of the unit test.Test Cases(TestCASE): The description of the test task, reflecting the test plan, method, technology and strategy. Content includes test objectives, test environments, input data, output data, test steps, expected results, test scripts, and more. It is an inspection behavior that allows us to write high-quality code. It is a design behavior that is conducive to the improvement of our programming ability. It is a document-writing behavior that allows our programs to be documented. Xcode has a built-in Ocunit Unit test framework. Prior to XCODE5, there was an option to build a project that would allow us to choose whether to create a project with unit test target, whereas in XCODE5 a project would default to the target of a unit test. Before XCODE5, it's okay to build a project without checking the unit test, and you can add a unit test target yourself. In the pop-up selection box Ios-->other---> Cocoa Touch Unit testing Bundle here looks OK, but still one step, after clicking on Run, long-press to generate test, click Test to open Testing, A hint will be generated: 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 the edit scheme (or the menu Product->edit scheme) to pop up the scheme form. Select Test, and then click on the + sign to add a scheme to select the previously created Coredatademotest and click AddDescription:In Xcode5, the test class must inherit from Xctestcase. The test class must inherit from Sentestcase before Xcode5. To run a test case:Command + U. Press and hold the Run button to select the test in the list, generally do not need to set up a testing function, the general program comes with a test target inside the testing class,
There are several methods:
1.-(void) SetUp: Call 2 before each test method executes. -(void) TearDown: 3 is called after each test method executes. -(void) Testxxx: The test method named XXX before all is to write the module after the repeated run,stop, more trouble, unit testing can be a good solution to this problem, well, write the more chaotic, follow-up in the finishing,
iOS unit Test First knowledge (xctestcase)