質問

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