GlobalVariable random at every login, also in parallel: so GlobalVariable for just a single Test Suite?

I need something random at each login, I’m using a code like this:

def now = new Date()
GlobalVariable.timestampEachLogin = now.toString()

And everything works good, but when I’m in parallel execution in a Test Suite Collection it fails. Because, let’s say I call three test suites with login test case in it: my GlobalVariable.timestampEachLogin is set to latest login value of the three. Just the latest, not one different for each test suite as I thought,

How to solve this?

Maybe something like a GlobalVariable for each Test Suite?

Dear Hanh Tran, thanks for your answer.

This is not my problem. I already use that .format. I need the random variable for each test suite when I execute them in parallel mode. Because a test suite call many test case with that GlobalVariable and it changes in every test suite.

So I need a GlobalVariable for each Test Suite, not just for all parallel execution. Is it more clear now?

If you really want a random value in that case, I would suggest using the following format instead for ‘now’ varliable:


It will get current time to extract miliseconds so that you can avoid duplicate/latest values for executing Test Suite Collection in parallel