I have created a new Xcode 4.2 Cocoa project, a cocoa library. By default, the unit tests come with the following unit test:
- (void)testExample
{
STFail(@"Unit tests are not implemented yet in learning01Tests");
}
If I press ⌘U I can see the test building and failing as expected. Now, I add the new following lines in order to test an external class I have created:
#import "svc01.h"
- (void)testMyClass
{
svc01* svc = [[svc01 alloc]init];
int expected = [svc addTwoNumbers:10 :10];
STAssertTrue(21 == expected, @"It should fail!");
}
I can see both tests (the default and my method) failing as expected. The issue is that sometimes, even if I press the command Test, it popups the message "Build succeed" and then "Test succeed" but if I look at the output console it says "tests run 0"
Is there anything wrong am I doing?
UPDATE
Right now I have changed the signature of my test methods and it does not work anymore. I have this:
#import <SenTestingKit/SenTestingKit.h>
@interface learning01Tests : SenTestCase
- (void)sumTwoIntegerShouldPass;
- (void)sumTwoZeroShouldThrow;
@end
- (void)sumTwoIntegerShouldPass
{
svc01* svc = [[svc01 alloc]init];
int expected = [svc addTwoNumbers:10 :10];
STAssertTrue(20 == expected, @"It should fail!");
}
- (void)sumTwoZeroShouldThrow
{
svc01* svc = [[svc01 alloc]init];
int expected = [svc addTwoNumbers:0 :0];
STAssertTrue(21 == expected, @"It should fail!");
}
And this is the Xcode output:
-bfxnldmmxzsspnbglmrpwsnweqkd/Build/Products/Debug/learning01Tests.octest(Tests)' started at 2011-12-26 14:45:26 +0000
Test Suite 'learning01Tests' started at 2011-12-26 14:45:26 +0000
Test Suite 'learning01Tests' finished at 2011-12-26 14:45:26 +0000.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds
Test Suite '/Users/raffaeu/Library/Developer/Xcode/DerivedData/learning01-bfxnldmmxzsspnbglmrpwsnweqkd/Build/Products/Debug/learning01Tests.octest(Tests)' finished at 2011-12-26 14:45:26 +0000.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.002) seconds