Reputation: 4318
I have isolated all the request alone in One Test Suite. I need to collect each api call time Taken..
Every Functional Test Case will call Request Test Suite using Run Test Case option.
I have following code in the script assertion of each request.
def endpoint = messageExchange.getEndpoint()
uri = endpoint.replace("baseurl","")
log.info("Current URI: "+uri)
uri = "t_"+uri
def headers = messageExchange.getResponseHeaders()
bytes= headers["Content-Length"].get(0)
log.info("Number of Bytes: "+ bytes)
timeTaken = messageExchange.getTimeTaken().toString()
values = timeTaken + ";"+ bytes
context.testCase.setPropertyValue(uri, values)
I expected that the uri would be created as the key and timeTaken and bytes are values. When run the request (from Request Test Suite) it creates the property.
But Functional Test Case calls this request from other Test suite it does not create such property.. How to resolve this? I see the work around run the each request and get the property created so that on next run it would be updated.. But the problem is when starting test suite I am deleting all the properties and values. So again it is a mess up.. Can someone let me know how to resolve this issue?
Upvotes: 0
Views: 171
Reputation: 28634
you can add a result to a csv file directly after execution like this:
new File('out.csv').append( "$uri; $timeTaken; $bytes\n" )
Upvotes: 1