我在XCTestCase类中有几个测试用例,例如test1、test2等。我只想在传递testPrecondition的情况下运行test1, test2。我怎样才能做到这一点呢?
发布于 2015-09-22 23:30:12
您必须重写XCtest的testInvocations类方法。下面的例子来自Github,代码是不言自明的。
+ (NSArray *)testInvocations
{
BOOL onlineTests = [[[[NSProcessInfo processInfo] environment] objectForKey:@"ONLINE_TESTS"] boolValue];
if (!onlineTests)
return [super testInvocations];
NSMutableArray *testInvocations = [NSMutableArray new];
for (NSInvocation *invocation in [super testInvocations])
{
if (![NSStringFromSelector(invocation.selector) hasSuffix:offlineSuffix])
[testInvocations addObject:invocation];
}
return [testInvocations copy];
}如果您想要决定在运行时=>期间运行哪个测试,那么您的测试(依赖项)中有一种代码气味,这意味着您正在做错误的测试。
https://stackoverflow.com/questions/32715046
复制相似问题