How to get value of multiple variables from one test case to another, without using global variable

How to get values of multiple variables from one test case to another, without using global variable.
image

In TC2 & TC3 , how to retrieve the value of firstName, middleName, lastName form TC1.

Also how to get Testcase Variable from TC 1 and Use it in TC2 & TC3.

image

@kazurayam

Why? It’s easiest.

Otherwise you should use WebUI.calTestCase.
You need to write one more test case “Controller” which calls TC1, TC2, TC3.
TC1 can return a value of type java.util.Map.
Controller pass the value contained in the Map to TC2 and TC3

I am able to get only one variable value. Is there way to pass the variable name in TC_2 and get the value?

TC1:

String firstName       =  'abc'
String middleName      =  'xyz'
String lastName        =  'qwerty'

return firstName
TC2:

String returnString = WebUI.callTestCase('TC1')

println returnString   // output - abc

@kazurayam said:

TC1 can return a value of type java.util.Map.

So, instead of returning only the firstName variable, build a map containing all variables you need and return that.

1 Like

TC1

Map m = ["firstName": "abc", "middleName": "xyz", "lastName": "qwerty"]
return m

TC2

Map m = WebUI.callTestCase("TC1")
println(m.firstName)
println(m['xyz'])
println(m.get('qwerty'))
2 Likes

Thanks @kazurayam.