Information Technology Reference
In-Depth Information
Creating a class for testing
Testing doesn't modify your main source code. It's an external process, and it leaves your main build code un-
changed.
For this example, create a new class called MathMachine to hold some basic math code. Right-click the Un-
itTest group in the Project Navigator, select New File, choose the Objective-C class option, and set it to be a
subclass of NSObject . Save the file as MathMachine . Xcode adds a header and implementation file to the
Classes group in the usual way.
NOTE
Because this project is called UnitTest, the UnitTest group holds the main source code. The unit testing code is in
the UnitTestTests group. In a project with a different name such as ProjectX, the unit testing code would be in Pro-
jectXTests—and so on.
MathMachine is going to unleash the power of gigahertz computing by adding together two integers— inputA
and inputB —and storing them in a property called sumAB . Add the following code to the header file, as
shown in Figure 17.4:
#import <Foundation/Foundation.h>
@interface MathMachine : NSObject {
int inputA;
Search WWH ::




Custom Search