0

I am using Initial Script to initialize few variables, one of them is a UTC timestamp connected value. I have 5 requests in my Test, first requests executed correct but last are not, because time connected variable is expired for API I test. I mean while first tests executed this variable is expired because my API is time sensitive.

Can I initialize some variables before every request, but not before all of them?

I know that I can create separate tests for every request but it's not cool and I want to hold all of them under one test.

Thanks!

Dmytro Zarezenko
  • 10,526
  • 11
  • 62
  • 104

1 Answers1

2

One way is to update that variable with the current UTC at the ​end​ of each request using a script. You typically use the script to perform assertions; however, you can also use variable.set in a request's script.

Another way is to use the {{timestamp}} function which returns the unix timestamp/epoch (seconds, not milliseconds).

If you require the ISO-8601 format of UTC, you can also use {{utc_datetime}}.

mansilladev
  • 1,010
  • 8
  • 16
  • It works, thanks. BTW, looks like `{{timestamp}}` returns not UTC timestamp, or I am wrong? – Dmytro Zarezenko Oct 05 '15 at 16:19
  • 2
    ```{{utc_datetime}}``` appended to answer. ISO-8601. This along with a bunch of other nice helper functions you get with Runscope are listed [here](https://www.runscope.com/docs/api-testing/variables). – mansilladev Oct 05 '15 at 16:24