robotcodedev / robotcode

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

[QUESTION] robotcode-runner setup and execute tests from command line. #320

Closed S7ud closed 4 days ago

S7ud commented 4 days ago

Not sure if this is a bug or not. I have set up my robot.toml file with "python-path" with a relative path to any resources like .resource files and locator files. I have set "paths" to src/test_framework/tests/ but my tests are in src/test_framework/tests/<component>/test_cases/

on the command line if I do: robotcode robot src/test_framework/tests/<component>/test_cases/ it looks like the robot.toml file is not used as the resources are not found and the output goes in the default "results" dir instead of my specified output-dir = "src/test_framework/output" if I give no path then it works file like: robotcode robot. with this it finds all the tests and executes.

if I remove the paths setting then when I run a test it seems to look through every folder up to that test but it does work. but again if I give a path on the command line like robotcode robot src/test_framework/tests then the resources are not found etc..

Can you advise if this is a bug or I'm doing something wrong please?

Desktop (please complete the following information):

d-biehl commented 4 days ago

do you have another robot.toml or pyproject.toml in that path? Or do you have a .git folder in that path?

S7ud commented 4 days ago

there is Scripts.toml , .gitmodules and .gitignore`

only one robot.toml

d-biehl commented 4 days ago

Ok, you have a .gitmodules file then you are using git submodules and every submodules has it's own .git folder. robotcode tries to find a valid project root, if you give a path at command line then starting from this path or if you give no path starting from the current directory, robotcode looks for a robot.toml, pyproject.toml or a .git folder. if robotcode finds one of them, then this is the start folder and then robotcode tries to load a robot.toml or pyproject.toml file if one exists. If your testcases are in a git submodule then robotcode finds the .git folder from this submodule and thinks this is the project root.

can you call robotcode with the verbose command? like this:

robotcode --verbose config show <path>

then you will get some output, where you can verify the project root, the config files robotcode loads and the current configuration.

instead of calling the *.robot files directly, another approach is to use robots --suite, --test, --include and --exclude command line arguments. With this approch all tests in reporting gets the same name and id and you can compare results better.

Configure your path in the robot.toml and then you only need to call something like:

robotcode robot --test "test case name"

or

robotcode robot --suite "component1"

or

robotcode robot --include "wip"

if you want to find out wich tests are runs with a specific combination of the commandline arguments you can use robotcode discover command like this:

robotcode discover tests --suite component1 --exclude wip

hope this helps a bit?

S7ud commented 4 days ago

This helps a lot thanks. Its starting to make more sense now.

d-biehl commented 4 days ago

cool, then I close this ;-)

btw in the next version I introduced 2 command line switches for the robot code, --root where you can define the root directory of the project and another --no-vsc to disable the detection of the root directory via the presence of a .git folder