Information Technology Reference
In-Depth Information
@implementation UnitTestTests
- (void)setUp {
[super setUp];
//Set up code here
}
- (void)tearDown {
// Tear-down code here.
[super tearDown];
}
-(void) testMathMachineSum
{
MathMachine *testMathMachine =
[[MathMachine alloc] initWithSum: kA and: kB];
STAssertTrue(testMathMachine.sumAB == kExpectedSum,
@”Sum incorrect. Expected %i, got %i”,
kExpectedSum, testMathMachine.sumAB);
[testMathMachine release];
}
@end
FIGURE 17.7
Implementing a test method
Understanding STAssert macros
The core of the test is in the line that begins STAssertTrue . This is one of the special macros included in the
test framework. The full list is shown in Table 17.1.
Search WWH ::




Custom Search