我使用OCMock試圖測試NSURLConnection的行爲這裏是不完整的測試:使用OCMock期待的分類方法的產量「[NSProxy doesNotRecognizeSelector」 ...]」
#include "GTMSenTestCase.h"
#import <OCMock/OCMock.h>
@interface HttpTest : GTMTestCase
- (void)testShouldConnect;
@end
@implementation HttpTest
- (void)testShouldConnect {
id mock = [OCMockObject mockForClass:[NSURLConnection class]];
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:mock startImmediately:NO];
[[mock expect] connection:connection didReceiveResponse:OCMOCK_ANY];
}
@end
當嘲諷帶班分類方法,其中委託方法連接:didReceiveresponse:是,我得到的錯誤:
Unknown.m:0:0 Unknown.m:0: error: -[HttpTest testShouldConnect] : *** -[NSProxy doesNotRecognizeSelector:connection:didReceiveResponse:] called!
有沒有人有這個問題