Forum Discussion

autoscout24's avatar
autoscout24
Contributor
14 years ago

TearDown TestRunner results

Hi Support Team,


def sNotes;
def list = new ArrayList();
def item;
count = 0
for( r in testRunner.results )
{
count++
if (r.toString().indexOf ("Request") != -1)
{
item = "TestStep < " + r.testStep.name + " > finished with status < " + r.status + " > Time Taken ::< " + r.timeTaken + " > ms " + "\n\n" + "----------------------------"+ r.testStep.name + " Request Message-----------------------" + "\n\n" + r.testStep.getProperty("request").getValue() +"\n\n" + "----------------------------" + r.testStep.name +" Response Message-----------------------" +"\n\n"+ r.testStep.getProperty("response").getValue()+ "\n\n" + "----------------------------"+ r.testStep.name + " Assertions-----------------------" +"\n\n"+ r.messages;
}
else
{
item = "TestStep < " + r.testStep.name + " > finished with status < " + r.status + " > Time Taken ::< " + r.timeTaken + " > ms " +"\n\n";
}
list.add(item);
}
sNotes = list.toString();


It is important for us to document the failed test request & response so we are using the above code in the test case tear down method . The Method works fine if we use simple parameters in the xml request (refer eg 1), but when we use the expressions in the xml as defined in eg 2, we cannot able to get the exact value of the expression in the request


eg 1
testStep.TestRequest
<web:request>
<profile_id>DIR_DE</profile_id>
</web:request>
r.testStep.getProperty("request").getValue() from the above code got the same message in the request.



eg 2
testStep.TestRequest
<web:request>
<profile_id>${#TestCase#Group1}</profile_id>
</web:request>
in this case also, r.testStep.getProperty("request").getValue() from the above code got the same message in the request.
That means '${#TestCase#Group1}' is displayed same as in the request. We want the real value of that parameter 'Group1' to be displayed in the request.
Like how it displays in TestCase Log (double clik the test request method--> Request Message, Response Message, Properties, etc.)


Would be great if you provide us some suggestion on the above.

Thank you

Regards
Vijay

1 Reply

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    You should be able to access the raw request data, but this contains the headers as well as the request body:


    def rawRequest = new String( r.rawRequestData )


    If you need to remove the headers, you can do this as well:


    def rawRequest = new String( r.rawRequestData ).split('\r\n\r\n')[1]


    The above should give you just the request body content. Good luck!

    Regards,
    Dain
    eviware.com