Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Crashes when running parameterized tests #513

Closed
conradev opened this issue May 8, 2015 · 1 comment
Closed

Crashes when running parameterized tests #513

conradev opened this issue May 8, 2015 · 1 comment

Comments

@conradev
Copy link

conradev commented May 8, 2015

I have a protocol with two concrete implementations. I wrote tests for the protocol that look like this:

+ (NSArray *)testInvocations {
    NSMutableArray *testInvocations = [[super testInvocations] mutableCopy];

    NSArray *resolvers = @[[BFWebViewAppLinkResolver sharedInstance], [BFXMLAppLinkResolver sharedInstance]];

    unsigned count;
    Method *methods = class_copyMethodList(self, &count);
    for (unsigned i = 0; i < count; i++) {
        SEL selector = method_getName(methods[i]);
        NSString *name = NSStringFromSelector(selector);
        if ([name hasPrefix:@"test"] && [name hasSuffix:@"WithResolver:"]) {
            for (id<BFAppLinkResolving> resolver in resolvers) {
                NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self instanceMethodSignatureForSelector:selector]];
                [invocation setSelector:selector];
                [invocation setArgument:(void *)&resolver atIndex:2];
                [invocation retainArguments];
                [testInvocations addObject:invocation];
            }
        }
    }

    return [testInvocations copy];
}

...

- (void)testPlatformFilteringWithResolver:(id<BFAppLinkResolving>)resolver {
    ...
}

Currently, xctool crashes here. Are there any plans to support these kinds of tests at some point in the future?

It's unfortunately causing issues with this pull request.

@ExtremeMan
Copy link
Contributor

Supporting such kind of tests would be very hard in xctool. It is so because we rely on unique test names in some places. In your case there will be several test invocations of testPlatformFilteringWithResolver:. This breaks xctool. Closing for now. Sorry for that. (Also I see that your PR could be now merged and we aren't a merge blockers anymore).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants