OCUnit Tip: You Only Need a .m File

April 25, 2012

If you are writing OCUnit tests, then you should only have a source (.m) file. There is no need for a header (.h).

Why no header (.h)?

  • test cases are, by nature, private implementation details
  • no need for a public interface (test cases are never imported by other test cases)
  • it is completely legal Objective-C to have the @interface and @implementation in the same file
// BTSPreferredTransferTest.m

#import <SenTestingKit/SenTestingKit.h>

@interface BTSPreferredTransferTest : SenTestCase

@implementation BTSPreferredTransferTest

- (void)testSomethingUseful
    // Test implementation