robotcodedev / robotcode

RobotFramework support for Visual Studio Code
https://robotcode.io
Apache License 2.0
168 stars 13 forks source link

[BUG] Cannot rename suite #248

Closed simonmeggle closed 2 months ago

simonmeggle commented 2 months ago

Describe the bug Inconsistency between possibilities on CLI and robot.toml.

To Reproduce Steps to reproduce the behavior:

example.robot

*** Test Cases ***
My Test
    Log    Done.

Suite name from filename:

bash-5.1$ robot example.robot 
==============================================================================
Example :: This is a minimal Robot Framework suite. You can execute it with...
==============================================================================
My Test                                                               | PASS |
------------------------------------------------------------------------------
Example :: This is a minimal Robot Framework suite. You can execut... | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Output:  /home/simonmeggle/Documents/01_dev/robotmk-example-suites/minimal/output.xml
Log:     /home/simonmeggle/Documents/01_dev/robotmk-example-suites/minimal/log.html
Report:  /home/simonmeggle/Documents/01_dev/robotmk-example-suites/minimal/report.html

Set suite name with --name:

bash-5.1$ robot --name xxx example.robot 
==============================================================================
xxx :: This is a minimal Robot Framework suite. You can execute it with `ro...
==============================================================================
My Test                                                               | PASS |
------------------------------------------------------------------------------
xxx :: This is a minimal Robot Framework suite. You can execute it... | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Output:  /home/simonmeggle/Documents/01_dev/robotmk-example-suites/minimal/output.xml
Log:     /home/simonmeggle/Documents/01_dev/robotmk-example-suites/minimal/log.html
Report:  /home/simonmeggle/Documents/01_dev/robotmk-example-suites/minimal/report.html

Setting --name with robot.toml fails: robot.toml

default-profiles = [
    "TEST"
]

[profiles.TEST]
name = "xxxx"
/home/simonmeggle/.vscode/extensions/d-biehl.robotcode-0.78.4/bundled/tool/robotcode --default-path . debug --no-debug -- --parse-include example.robot --name xxxx --suite xxxx.Example --by-longname xxxx.Example
[ ERROR ] Suite 'Minimal' contains no tests after model modifiers.

Try --help for usage information.

As Robotcode takes the cwd as root suite, I also tried:

default-profiles = [
    "TEST"
]

[profiles.TEST]
name = "Minimal.xxx"

Result:

/home/simonmeggle/.vscode/extensions/d-biehl.robotcode-0.78.4/bundled/tool/robotcode --default-path . debug --no-debug -- --parse-include example.robot --name Minimal.xxx --suite Minimal.xxx.Example --by-longname Minimal.xxx.Example
[ ERROR ] Suite 'Minimal' contains no tests after model modifiers.

Expected behavior I expect setting the suite name in robot.toml as it is possible on the CLI.

Desktop (please complete the following information):

Additional comment I am not sure if this is really a bug. But I guess for Robotcode the "root" suite seems to be the parent folder (Minimal) - on the CLI it is the robot file itself.

d-biehl commented 2 months ago

ok, this seems to be a problem in the RobotFramework itself, if you use a prerunmodifier and set the name of the suite via the command line, the prerunmodifier is executed first and then the name of the suite is changed.

The debugger/runner in VSCode needs a way to run testcases with long names (e.g. suite.subsuite.subsuite.testcase1) because the --test argument uses wildcards, is case insensitive and so on. But you can have test cases with same names that are only differs in case or space count. At runtime there is only a warning, but all test cases are executed.

I think that changing the name, doc and metadata and test tags (see the corresponding command line arguments) of the suite should be done before calling the pre-run modifiers. And I think we need to create an issue for the robot framework ;-)

@simonmeggle, if you have the time and inclination, maybe you can create this issue?

You can use this modifier as an example: https://github.com/robotcodedev/robotcode/blob/main/packages/modifiers/src/robotcode/modifiers/longname_modifiers.py

if not, then it needs some time ;-)

d-biehl commented 2 months ago

And by the way, there is also the new Name setting of the suite, see here https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#suite-name

simonmeggle commented 2 months ago

Thanks a lot for investigating so far, Daniel. I will take care for this.