citrusframework / citrusframework/citrus
Accessing variables in report from TestCase object
- Dominant language
- Java
- Stars
- 485
- Forks
- 155
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 6
Description
**Citrus Version**
2.8.0
**Question**
1) I noticed some differences in how two below methods work.
`variable("a", "val1");`
and
`createVariable("b", "val2");`
When I create variables with the use of the method `variable`. I can access these variables in the test report via the `TestCase` object. But when I create variables with the use of `createVariable`, these variables are not accessible via `TestCase` object in a report.
Is this is expected behavior?
2) Is it expected that variables created in test actions are not accessible from the `TestCase` object?
**What I've tried so far**
1) I wrote the following short test:
`@CitrusTest
public void testVariables() {
variable("a", "val1");
variable("b", "val2");
createVariable("c", "val3");
createVariable("d", "val4");
}`
and I've checked the values of variables in `TestCase`.

Only two first variables were created.
2) Custom action
```
public class CustomTestAction extends AbstractTestAction {
public CustomTestAction() {
this.setName("custom-test-action");
}
@Override
public void doExecute(TestContext context) {
Map variables = someCustomTestActions();
this.createdLocalVariable(context, variables);
this.createGlobalVariable(context, variables);
}
private Map someCustomTestActions() {
return Collections.singletonMap("myCustomVar1", "myCustomVarValue1");
}
private void createdLocalVariable(TestContext context, Map variables) {
context.getVariables().putAll(variables);
}
private void createGlobalVariable(TestContext context, Map variables) {
context.getGlobalVariables().putAll(variables);
}
}
```
Test
```
@CitrusTest
public void testCustomTestAction() {
this.run(new CustomTestAction());
}
```
Variables were created:

No variables to access in the test report:

**Additional information**
Contributor guide
Research direction
Start by reproducing the two tests shown in the issue: testVariables and testCustomTestAction, then trace how variable(), createVariable(), TestContext variables, and global variables are exposed through the TestCase used by the report. Done means the behavior is documented or corrected so variables created through these paths have a clear, consistent report visibility.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100