You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Perform code under test
[parser findNearbyPlaceNameForLatitude:-10.0 longitude:-10.0];
// Validate result
STAssertTrue([self waitForCompletion:3.0], @"Failed to get any results in time");
STAssertNotNil(searchResult, @"Didn't expect an error");
STAssertEquals([searchResult count], (NSUInteger)0, @"Should not find any results in the middle of nowhere: %@", searchResult);
STAssertEquals(totalFound, 0U, @"Unexpected number of total results");
It calls that method which is in my code and under test
// Perform code under test
[parser findNearbyPlaceNameForLatitude:-10.0 longitude:-10.0];
above method is in code file rather than test class but when I look at Nocilla samples, it does not call actual methods of code. It samples are all in test file and independent of method which I actually want to test.
My goal is to test a webservice call, validate its url, host etc, body parameters and only mock that part which interact with live server. How can I achieve that.
Thanks in advance.
The text was updated successfully, but these errors were encountered:
Hi,
I have read this article for unit testing API calls and I understood the concept of unit testing with mock objects to test API calls.
http://www.infinite-loop.dk/blog/2011/09/using-nsurlprotocol-for-injecting-test-data/
Inside code of above article sample
[self loadCannedResultWithName:@"MiddleOfNowhere"];
mockParser = [OCMockObject partialMockForObject:parser];
[[[mockParser stub] andCall:@selector(returnCannedResultForRequest:)
onObject:self] sendRequestWithURLString:[OCMArg any]];
It calls that method which is in my code and under test
// Perform code under test
[parser findNearbyPlaceNameForLatitude:-10.0 longitude:-10.0];
above method is in code file rather than test class but when I look at Nocilla samples, it does not call actual methods of code. It samples are all in test file and independent of method which I actually want to test.
My goal is to test a webservice call, validate its url, host etc, body parameters and only mock that part which interact with live server. How can I achieve that.
Thanks in advance.
The text was updated successfully, but these errors were encountered: