Setting Up Logic Testing in iPhone development



To set up a logic–unit-test bundle in a project:


1. Add an iPhone OS unit-test bundle target to the project. Name the target LogicTests.


2. Set the LogicTests target as the active target.


3. Add a group called Tests to the Group & Files list, and select that group in the list.


4. Add a unit-test class to the unit-test-bundle target. Each unit-test class in the bundle makes up a test suite.


Choose File > New, select the iPhone OS unit-test class template, and click Next.


Name the class LogicTests (you can use any name here, too).


Select the option to create the header file.


 Ensure that LogicTests is the only target selected in the target list.


 


5. Change LogicTests.h so that it looks like this:


#import <SenTestingKit/SenTestingKit.h>


#import <UIKit/UIKit.h>


@interface LogicTests : SenTestCase {


}


 


6. Change LogicTests.m so that it looks like this:


#import \"LogicTests.h\"


@implementation LogicTests


- (void) testFail {


STFail(@\"Must fail to succeed.\");


}


 


7. Set the base SDK for the project to iPhone Simulator 3.0 or later.


 


8. Set the active target to LogicTests and choose Build > Build. If the unit-test bundle is configured correctly, the build fails and Xcode displays an error message in the text editor.


 


9. Now make the test case pass by changing the highlighted lines in LogicTest.m:


#import \"LogicTests.h\"


@implementation LogicTests


- (void) testPass {


STAssertTrue(TRUE, @\"\");


}


 

Editor: ankita Added on: 2013-03-07 15:45:21 Total View:350







Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---