문제

Here's the method I want to test:

-(bool) myMethod:(NSArray*) argArray {
    self.mArray = argArray;
    if (self.mArray == nil) {
        NSLog(@"Error - array is nil");
        return NO;
    }
    return YES;
}

I am not quite sure how to setup a test for this method. I want to test that if argArray is nil then it returns NO. I also want to test that if argArray is not nil then I return YES.

I'm not sure if I should have a mock NSArray object and see if it passes/fails, or if I should just use a real NSArray object.

도움이 되었습니까?

해결책

In this example you can use real object. You should use mocking when you need to, that is when you stub any method.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top