Are header files necessary for Objective-C Unit Tests?
Are header files necessary for Objective-C unit tests?
When using OCUnit, GHUnit, or GTM Unit Tests, I don't see the point of creating the header file for the unit test. It feels like it's just another file I need to keep updated if I decide to change my unit tests.
Tests are self-contained within a file and I don't reference one set of unit tests in another testing file.
Example: SetupTests.m (Using GHUnit)
// SetupTests.m
@interface SetupTests : GHTestCase
{}
@end
@implementation SetupTests
- (void) testMath {
GHAssertTrue((1+1)==3, @"Compiler isn't feeling well today :-(" );
}
- (开发者_开发百科void) testFirstUT {
GHAssertEquals(1, 2, @"Should fail");
}
- (void) testSecondUT {
GHAssertEquals(1, 1, @"Should pass");
}
@end
No, they are not required. You are correct the header files primary function is to separate the interface from the implementation so that you can include the method declaration (and such) from other places.
精彩评论