使用OCUnit編寫單元測試時,可能會忽略公共接口(.h)中的測試方法定義。但OCUnit關於公共接口中測試方法定義的最佳做法是什麼?您是否需要在OCUnit的測試用例類中的公共接口中定義測試方法
ModelTest.h(沒有定義的測試方法)
@interface ModelTest : SenTestCase
@end
ModelTest.m
@implementation ModelTest : SenTestCase
- (void) testCreation {
...
}
@end
ModelTest.h(測試方法定義)
@interface ModelTest : SenTestCase
- (void) testCreation;
@end
我個人認爲這是更好地在公共接口中反映公共測試方法的定義。但是,最佳做法是什麼?我們無法避免在公共接口中聲明這些方法嗎?
感謝有趣的是不要使用.h文件進行單元測試。 – Vladimir 2013-03-25 22:31:00