Database Reference
In-Depth Information
return;
}
STFail(@"Call did not generate exception");
}
-(void) testGetForecastWebServiceEndpointMissingStartDate {
@try {
[WebServiceEndpointGenerator
getForecastWebServiceEndpoint:@"03038"
startDate:nil endDate:testEndDate];
} @catch (NSException * e) {
STAssertEqualObjects(@"Missing Argument Exception",
e.name, @"Wrong exception type");
return;
}
STFail(@"Call did not generate exception");
}
-(void) testGetForecastWebServiceEndpointMissingEndDate {
@try {
[WebServiceEndpointGenerator
getForecastWebServiceEndpoint:@"03038"
startDate:testStartDate endDate:nil];
} @catch (NSException * e) {
STAssertEqualObjects(@"Missing Argument Exception",
e.name, @"Wrong exception type");
return;
}
STFail(@"Call did not generate exception");
}
-(void) testGetForecastWebServiceEndpointDatesInWrongOrder {
@try {
[WebServiceEndpointGenerator
getForecastWebServiceEndpoint:@"03038"
startDate:testEndDate endDate:testStartDate];
} @catch (NSException * e) {
STAssertEqualObjects(@"Date Order Exception",
e.name, @"Wrong exception type");
return;
}
STFail(@"Call did not generate exception");
}
The interesting bit in these test cases is that, because what we're interested in is whether
or not the tested method throws an exception, what we do is wrap the invocation of
the method in a try block, and if the exception is thrown, compare the exception name
with the name we were expecting to see. If the name is wrong, the assert will fail. If the
exception is not thrown, we won't return out of the test in the catch clause, and will
explicitly fail.
 
Search WWH ::




Custom Search