After the software testing this course began to practice software testing methods, because the individual more emphasis on iOS development, so began to the iOS platform software Testing technology research
Apple integrated the new Unit testing tool, Xctest, in its own development tool Xcode in 2014.
First, to talk about what is unit testing
Unit testing refers to the process of testing the most basic elements of a program, such as a function, a menu, an interface, and the smallest executable unit.
Individual understanding of unit testing can ensure the robustness of the program, but also to develop defensive programming good habits
Second, xctest framework
1. Overall look how to use it
The usage is very simple, it is plain to realize that a xctest subclass can be
Example: Creating a First_test test class
@interface First_test:xctest
There are two functions that must be implemented
-(void) setUp;
-(void) TearDown;
Is the two callback function that represents the start of the test and the end of the test, where the variable is initialized
2. First Test
Import a class target to be tested in the FIRST_TEST.M test class header
#import "Target.h"
And a new test method in FIRST_TEST.M-(void) testexample{...}, the test method begins with the
Then you write a small piece of code in this method to test.
Here we deliberately construct a wrong method, because Carid is not equal to 100, so throw an error here
We see Xctassertequal (...) is an assertion statement, which the compiler judges here.
Xctest Framework is composed of various assertions, which facilitates the judgment of the results.
iOS test Tool Research (1)-----------xctest Unit Test