I'm attempting to test a method on my class that calls a class method on another class. The second class I'm calling is contained inside of a framework if that matters.
Simplified version of the method I'm trying to test. I just want to verify that the switch statement does what I expect by catching and verifying the call to [DataCapture trackEvent:].
- (void)beaconValue:(NSInteger)value
{
NSString* elementIdValue;
switch(value)
{
case 1:
elementIdValue = @"One";
break;
case 2:
elementIdValue = @"Two";
break;
case 3:
elementIdValue = @"Three";
break;
}
[DataCapture trackEvent:elementValueId];
}
Here is the test I wrote that I expect to work:
- (void)testCaptureData_1
{
id mockDataCapture = OCMClassMock([DataCapture class]);
OCMExpect([mockDataCapture trackEvent:@"One"]);
[[BeaconingService sharedBeaconingService] beaconValue:1];
OCMVerifyAll(mockDataCapture);
[mockDataCapture stopMocking];
}
My verify always tells me that the expected trackEvent method was not invoked, even if I change my expect to [OCMArg any]. Am I doing something obviously wrong or is the problem elsewhere (i.e. bad project setup?)
Aucun commentaire:
Enregistrer un commentaire