Variable in called test case unavailable


#1

I’m trying to create a test case that sets a handful of variables that can then be used in other tests. The problem is that I can’t access the info in those variables when I call it from another test case.

Example: Test Case A does a database lookup and stores the retrieved info to variables. On variable is ‘userEmail’ that I defined in Script Mode as userEmail = dbUserData.getValue(4, 1) and also created the variable in the Variable view called ‘userEmail’, string, and default value is ‘someEmail’.

When I run this test alone, variables are assigned correctly.

Now in Test Case B, I call Test Case A and try to use userEmail and get an error.
“println(userEmail)” throws “No such property: userEmail for class”.

I didn’t want to use global variables as I wanted to run this test concurrently with other cases using Test Case A.

What I’m I missing?


#2

Probably only one key thing:

Set up a static class containing a set of vars or a Map containing a set of vars. You can do this with a minimal Custom Keyword class.

Import the new custom keyword class statically into all tests that need it.

You can read about Maps here: http://docs.groovy-lang.org/latest/html/documentation/#_maps

You can read about custom keywords here:


#3

Looks similar to the following discussion: