question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting global variable in before suite actions

See original GitHub issue

Currently, 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:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
christophdcommented, Nov 13, 2017

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.

0reactions
svettwercommented, Jul 20, 2018

I just found #400, that will implement the requested feature. Therefore I’ll close this issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found