Get TimeTaken from a REST POST request
I'm trying to write the response times for SOAP and REST calls from the my test cases to a database. I have it working with one exception. The REST POST requests are giving me the following: ERROR:java.lang.NullPointerException: Cannot invoke method getTimeTaken() on null object
I'm using the TestListener.AfterRun event. Here is the relevant code:
for (myResult in testRunner.getResults())
{
if((myResult.testStep.config.type == "request") || (myResult.testStep.config.type == "restrequest")){
//if this is a request we want to get the amount of time it took
RequestDurationList.add(myResult.response.timeTaken)
//if the repsonse for the request takes longer than 2 seconds (2000 milliseconds)
//Mark it as an SLA Failure
if(myResult.response.timeTaken > 2000){
SLAFailureValue = "True"
}
}
}
My failure is on the BOLD and Italics line.
Why is this working for GET requests buy not POSTs?
(ALSO as a note I use this exact code on the SOAP side and I haven't seen any issues there)