OCMock과 함께 XCTest (iOS7, XCode5)를 작성하려고합니다.OCMock with iOS7을 사용하여 CLLocationManager에서 클래스 메서드를 모의 할 수 없습니다.
CLLocationManagerDelegate 프로토콜을 구현하는 클래스가 있고 CLLocationManager의 인스턴스 인 속성이 있습니다. (필자는 CLLocationManager의 인스턴스를 내 initialiser 메서드에 제공하여 런타임에 테스트하거나 테스트 할 수 있도록합니다.)
위임 클래스를 테스트 할 때 모의 CLLocationManager를 만듭니다.
[[[[mockLocationManager stub] classMethod] andReturnValue:kCLAuthorizationStatusDenied] authorizationStatus];
result = [delegateUnderTest doMethod];
//Do asserts on result etc etc
문제는, 엑스 코드 내 코드에 대해 불평 : 테스트에서
, 나는 이런 식으로 뭔가를 달성하고 싶다.test.m:79:68: Implicit conversion of 'int' to 'NSValue *' is disallowed with ARC
test.m:79:68: Incompatible integer to pointer conversion sending 'int' to parameter of type 'NSValue *'
kCLAuthorizationStatusDenied는 (TypeDef에 정의 된대로) 이해할 수있는 정수입니다. 그래서, 객체를 기대
[[[[mockLocationManager stub] classMethod] andReturn:kCLAuthorizationStatusDenied] authorizationStatus];
을 사용할 수 없습니다 ('andReturn'는 'ID'이다).
아이디어가 있으십니까?
감사합니다. 속임수를 쓰자. @kCLAuthorizationStatusDenied (괄호없이)를 시도했는데, 옳은 것으로 보였다. 그 여분 괄호 @ (kCLAuthorizationStatusDenied)는 나를 분류했다. –