1

I have a test case in SoapUI NG Pro which has the following steps:

  1. POST REST Request that starts a process
  2. JDBC Request where I check that the process Start Date has been logged to a database table
  3. Delay (to simulate the time it takes for the process to run)
  4. JDBC Request where I check that the End Date and Duration have been logged to the table

I would like to capture the timestamp of the POST Request to use within my assertions in steps 2 and 4.

I have looked around online and some people have mentioned using Events while others have mentioned using a Script TestStep but I haven't been able to get either to work.

I can get the POST Response timestamp but am looking for the Request timestamp in particular. I also noticed that there is a timestamp in the Request Log but again I don't know how to access that.

Any help would be greatly appreciated. Its probably also worth mentioning that I am using JavaScript instead of Groovy.

Rao
  • 20,781
  • 11
  • 57
  • 77
LiamTester
  • 13
  • 2
  • "am looking for the Request timestamp in particular" - what does it mean? If you want time taken for `POST` request test step, then it is possible to get it. Do you want that? By the way, `groovy` script is the best pair with SoapUI. – Rao Jan 30 '18 at 03:54
  • Yes that's what I'm looking for. I had some previous experience with JavaScript and started out my project using that as my scripting language. Unfortunately it would be too much work to switch to using Groovy at this point. – LiamTester Jan 30 '18 at 09:28
  • please check the answer to see if that helps. – Rao Jan 31 '18 at 07:01

1 Answers1

1

You can add a Script Assertion for the Soap Request test step and add the below statement in order to show the time taken.

log.info messageExchange.response.timeTaken

If you want the above value to be accessible in other steps, then use below(which stores the value to test case level, so that it is easy to access the test case property in other steps of the same test case):

context.testCase.setPropertyValue('TIME_TAKEN', messageExchange.response.timeTaken.toString())

In the later steps, use Property Expansion to read the test case level property value

def timeTaken = context.expand('${#TestCase#TIME_TAKEN}') as Integer
Rao
  • 20,781
  • 11
  • 57
  • 77