"if 조건"이 너무 많고 contions에서 배열 개수를 확인하는 복잡한 방법에 대해 OCMock을 사용하여 단위 테스트를 작성하는 방법.OCMock을 이용한 복잡한 방법에 대한 단위 테스트
- (BOOL)someMethod
{
BOOL bUploadingLocation = false;
CLLocation *newLocation = nil;
if([locationCallbacks count] > 0)
{
for(CLLocation* receivedlocation in locationCallbacks) {
//Print
}
newLocation = [locationCallbacks objectAtIndex:[locationCallbacks count] - 1];
}
else
{
return bUploadingLocation;
}
BOOL initialLocation = false;
CLLocation *lastKnownLocation = [[ASAppProfileService sharedInstance] getStoredLastKnownLocation];
if(lastKnownLocation == nil)
{
initialLocation = true;
}
BOOL checkedInstatusChange = false;
if([[CRMgr getSharedInstance] isCREnabled])
{
checkedInstatusChange = [[CRMgr getSharedInstance] orchestrateCROperationsWithLocation:newLocation];
}
BOOL lastGoodUploadIsWithinThresold = [MELocationUtils isLastAccurateUploadWithinThresold];
if(initialLocation || checkedInstatusChange || !lastGoodUploadIsWithinThresold)
{
BOOL bCanUpload = [[ASAppProfileService sharedInstance] canUploadData];
if(bCanUpload)
{
[[MEProtocolHelper sharedDataUploadManager] uploadLocationInformationPayload:newLocation];
bUploadingLocation = true;
}
else
{
//Print something
}
}
return bUploadingLocation;
}
어떻게 방법의 이러한 종류의 단위 테스트를 작성하기 : 여기 내 샘플 방법?