Forum Discussion
AlexKaras
13 years agoChampion Level 3
The only idea that I have at the moment (considering the fact that you are getting properly formatted SOAP response) is to try to disable the 'Stop on Error' option for the project and/or wrap the call to the GetAirportList() method with try/catch/finally and process the response in the catch/finally section(s).
BTW, in one of my projects (for the negative tests) I ended-up with the code like that (DelphiScript, but you should get an idea that illustrates my above suggestion):
...
boolExceptionThrown := false;
try
getWebService().MethodName(parameters);
except
boolExceptionThrown := true;
ExceptionMessageMatches(cExpected, ExceptionMessage, cProcNameMsgPrefix);
end;
if (not boolExceptionThrown) then // exception was not thrown at all
Log.Error(cProcNameMsgPrefix + 'Web service method did not throw expected exception',
'Expected: ' + cExpected);
...
//-----------------------------------------------------------------------------
function ExceptionMessageMatches(strExpected : string; strExceptionMessage : string;
strProcNameMsgPrefix : string = '') : boolean;
begin
if (StrMatches(strExpected, strExceptionMessage)) then
Log.Message(aqString.Format('%sExpected web service method call exception', strProcNameMsgPrefix),
PrettyPrintXML(strExceptionMessage))
else
Log.Error(aqString.Format('%sWeb service method threw unexpected exception', strProcNameMsgPrefix),
aqString.Format('Expected: '#13#10'%s'#13#10'Actual: '#13#10'%s',
PrettyPrintXML(strExpected), PrettyPrintXML(strExceptionMessage)));
end;
//-----------------------------------------------------------------------------
Hope, it might appear to be useful...
BTW, in one of my projects (for the negative tests) I ended-up with the code like that (DelphiScript, but you should get an idea that illustrates my above suggestion):
...
boolExceptionThrown := false;
try
getWebService().MethodName(parameters);
except
boolExceptionThrown := true;
ExceptionMessageMatches(cExpected, ExceptionMessage, cProcNameMsgPrefix);
end;
if (not boolExceptionThrown) then // exception was not thrown at all
Log.Error(cProcNameMsgPrefix + 'Web service method did not throw expected exception',
'Expected: ' + cExpected);
...
//-----------------------------------------------------------------------------
function ExceptionMessageMatches(strExpected : string; strExceptionMessage : string;
strProcNameMsgPrefix : string = '') : boolean;
begin
if (StrMatches(strExpected, strExceptionMessage)) then
Log.Message(aqString.Format('%sExpected web service method call exception', strProcNameMsgPrefix),
PrettyPrintXML(strExceptionMessage))
else
Log.Error(aqString.Format('%sWeb service method threw unexpected exception', strProcNameMsgPrefix),
aqString.Format('Expected: '#13#10'%s'#13#10'Actual: '#13#10'%s',
PrettyPrintXML(strExpected), PrettyPrintXML(strExceptionMessage)));
end;
//-----------------------------------------------------------------------------
Hope, it might appear to be useful...
Related Content
- 10 years ago
- 2 years ago
- 4 years ago
- 7 years ago
Recent Discussions
- 2 days ago
- 2 days ago
- 5 days ago