RED
RED copied to clipboard
Eclipse Variables not resolved on run from Execution/Project Explorer View
When (re)running a testcase from the "Project explorer" or "Execution" view, the Eclipse variables used in default launch configuration are not being resolved.
Reproduce: Set default launch configuration -> robot -> aditional robot Framework arguments: "--outputdir ${project_loc}\Results${current_date}"
Create robot suite: *** Test Cases *** Pass test log hello
Fail test Fail
Run scenario's:
Actual behaviour: Eclipse variables are resolved depending on where/how the test is started:
- Run suite using crtl+f11:
- Results in expected newly created folder using current date
- C:\Testware\Workspace[project name]\Results[current_date]\log.html
- Run suite using project explorer:
- Results in expected newly created folder using current date
- C:\Testware\Workspace[project name]\Results[current_date]\log.html
- Run single testcase using project explorer:
- Variables are not resolved and used as is:
- C:\Testware\Workspace${project_loc}\Results${current_date}\log.html
- Rerun using execution view:
- Variables are not resolved and used as is:
- C:\Testware\Workspace${project_loc}\Results${current_date}\log.html
Expected behaviour: Eclipse variables are always resolved when the test is started:
- Run suite using crtl+f11:
- Results in expected newly created folder using current date
- C:\Testware\Workspace[project name]\Results[current_date]\log.html
- Run suite using project explorer:
- Results in expected newly created folder using current date
- C:\Testware\Workspace[project name]\Results[current_date]\log.html
- Run single testcase using project explorer:
- Results in expected newly created folder using current date
- C:\Testware\Workspace[project name]\Results[current_date]\log.html
- Rerun using execution view:
- Results in expected newly created folder using current date
- C:\Testware\Workspace[project name]\Results[current_date]\log.html
OS: Windows 10 RED: 0.9.5
Hi,
thanks for reporting. I confirm this is reproducible for me
After having a look I found out that:
The project_loc variable is so-called dynamic variable which means that:
- it does not store a value but it's value is computed dynamically
- it may accept arguments
The problem here is that when project_loc is computed without arguments given it looks for an object selected in active view or file under edit in active editor. This leads to a situation in which:
project_locis properly resolved when tests are launched from Project Explorer by selecting a file (because a file is selected, so eclipse finds the project to which it belongs);project_locis properly resolved when tests are launched from editor - either from tables or from source editor, because eclipse finds file input of this active editor and then the project to which the file belong;project_loc_cannot be resolved when tests are launched from Project Exploring by selecting a test case(s); this is because a test case object is selected but it is not adaptable to IResource interface thus eclipse don't know how to obtain project to which it belongs;project_loccannot be resolved when tests are re-launched by button from Execution view; this is because either the selection inside this view is empty; however if it wouldn't the objects inside are also not adaptable to IResource.
For now I don't know yet how it should be properly fixed. The problem from 3rd point can be fixed by providing adapters, this would however lead to many different context menu options shown for test case as eclipse uses this mechanism for menu contributions. I don't know however how to fix 4th yet.
As of now you can also use workaround: you can provide an argument to project_loc. This argument is treated as project name and in such case eclipse will not look for selected object in active view/editor but instead it will get location of workspace and append the given name to a path. In such case all the cases described work fine.
In order to do it use: --outputdir ${project_loc:ProjectName}\Results${current_date} instead of --outputdir ${project_loc}\Results${current_date} where ProjectName after : is a name of your project.
Hi,
Thank you for the investigation and explanation. The suggested workaround has been implemented and is working for us.