Reputation: 3909
It should fail, but it's passing. So I assume my syntax is wrong somewhere (although it builds).
#import <Foundation/Foundation.h>
@interface FirstCocoaLibrary : NSObject
-(int)AddFirstNum:(int) i1 withSecondNum:(int) i2;
@end
#import "FirstCocoaLibrary.h"
@implementation FirstCocoaLibrary
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
- (int)AddFirstNum:(int) i1 withSecondNum:(int) i2{
return i1 + i2;
}
@end
#import <SenTestingKit/SenTestingKit.h>
#import "FirstCocoaLibrary.h"
@interface FirstCocoaLibraryTests : SenTestCase{
FirstCocoaLibrary *_adder;
}
@end
#import "FirstCocoaLibraryTests.h"
@implementation FirstCocoaLibraryTests
- (void)setUp
{
// Set-up code here.
_adder = [[FirstCocoaLibrary alloc] init];
}
- (void)tearDown
{
// Tear-down code here.
}
- (void)testExample
{
//STFail(@"Unit tests are not implemented yet in FirstCocoaLibraryTests");
}
- (void)ShouldAdd2Numbers {
int result = [_adder AddFirstNum:4 withSecondNum:5];
STAssertEquals(0, result, @"Test Failed at adding", result);
}
@end
Upvotes: 0
Views: 187
Reputation: 64002
OCUnit only automatically runs methods whose names start with test
. I don't think it's passing; it's not getting run at all. Rename ShouldAdd2Numbers
to testAddFirstNumWithSecondNum
.
Also note that Obj-C convention is for method names, and each section of a method name, to start with a lower-case letter. Thus, addFirstNum:withSecondNum:
Upvotes: 3
Reputation: 17143
That test is probably not running at all. It should be called testShouldAdd2Numbers
BTW, your methods should start lowercase;
EDIT
This darn keyboard is slow. Do what @Josh Caswell said. :)
Upvotes: 2