开发者

OCUnit: How to change the prefix of test-case methods?

开发者 https://www.devze.com 2023-03-29 06:14 出处:网络
Instead of the prefix test, I want to use spec because I prefer BDD vocabulary. E开发者_如何学Go.g., instead of:

Instead of the prefix test, I want to use spec because I prefer BDD vocabulary.

E开发者_如何学Go.g., instead of:

- (void)testExample

I want to call it:

- (void)specExample

How can I do this?


After reading the source code of SenTestingKit, I added the following file to the test target:"

// NSInvocation+SetTestMethodPrefix.m

@implementation NSInvocation (SetTestMethodPrefix)

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

@end

This works, but seems like a hack, especially since +[NSInvocation setTestMethodPrefix:] is private.

Is there a better way to do this?

0

精彩评论

暂无评论...
验证码 换一张
取 消