Вопрос

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