OCUnit:如何更改测试用例方法的前缀?

时间:2011-08-20 15:12:34

标签: ocunit sentestingkit

我想使用test而不是前缀spec,因为我更喜欢BDD词汇。

,例如,而不是:

- (void)testExample

我想称之为:

- (void)specExample

我该怎么做?

1 个答案:

答案 0 :(得分:1)

阅读source code of SenTestingKit后,我将以下文件添加到测试目标:“

// NSInvocation+SetTestMethodPrefix.m

@implementation NSInvocation (SetTestMethodPrefix)

+ (void)load {
    [self performSelector:@selector(setTestMethodPrefix:) withObject:@"spec"];
}

@end

这很有效,但看起来像是黑客,特别是因为+[NSInvocation setTestMethodPrefix:]是私有的。

有更好的方法吗?

相关问题