Problem
We use OCMock for mock objects in many of our unit tests. As part of our tests, to see how our code responds to server responses, we create an NSURLSessionDataTask object, and then try to use the "response" property on it.
The plot is thickening
Prior to iOS 9, the tests went fine. The property also works correctly in the normal reverse flow of an application on iOS 9.
However, with iOS 9 beta versions, tests fail at runtime with the error "unrecognized selector sent to instance." The property is present in the structure header and is not marked as deleted in the documentation.
This code example illustrates the problem:
NSURLSessionDataTask *task = [[NSURLSessionDataTask alloc] init];
NSLog(@"%@", task.response);
Theory
, . , @dynamic, .
unit test OCMock , iOS 8?
1
OCMock (3.1.5) .
, NSURLSessionDataTask OCMock. .
NSURLSessionDataTask *task = [[NSURLSessionDataTask alloc] init];
OCMockObject *mockTask = [OCMockObject partialMockForObject:task];
[[[mockTask stub] andReturn:urlResponse] response];