Setting global variable in before suite actions
See original GitHub issueCurrently, runner.getVariable()
isn’t available in Citrus before suite which extends TestRunnerBeforeSuiteSupport
.
What I am dong is:
runner.echo("My Value : ${extractedValue}");
final String myValue = runner.variable("tmp", "${extractedValue}");
variables.getVariables().put("Value", myValue);
This seems like a hack, could you please suggest a better way of doing it?
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
How to pass variables between test cases in a suite (the "right ...
1.) Creating “empty” GlobalVariables in a Profile, assigning values to those variables at runtime, then consuming them as a global variable in ...
Read more >Global Variables and Execution Profile - Katalon Docs
A global variable is a variable defined in the execution profile and can be used in a test case, test object, web service...
Read more >Python unittest setting a global variable correctly
This global variable is called feedback and has a default value of False . When I call setFeedback('y') the global variable will be...
Read more >Global Variable and BeforeSuite - Google Groups
At startup, I'm setting a global variable which is a testing context for Google AppEngine. The global variable seems to be properly set...
Read more >Set up Constant Variables in Selenium Automation Framework
Now pass your Constant Variables (URL, Username, and Password) as arguments to your Execute method of SignIn_Action class in your Global_Var_TC ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, now I see what you are trying to do.
It is not possible to add/set global variables via test action. Also the runner and test context that you access in the before suite is not the same instance that is used later in your test case. Therefore variables are not visible. This is a design concept that should avoid tests to be dependent on each other which is bad by nature. The autowired global variables will also not help because of this.
I see the relevance of your code getting the access token once at the very beginning. I would suggest to use a test behavior for that that is applied to the before test lifecycle. The before test lifecycle has access to the test context of the actual test meaning that setting new variables in before test are also visible in test itself.
This could be a better solution for you.
I just found #400, that will implement the requested feature. Therefore I’ll close this issue.