robotcodedev / robotcode

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

[BUG] 'Run' Robot Test button not visible in editor #101

Closed jura84 closed 1 year ago

jura84 commented 1 year ago

Describe the bug When created simple Robot example in VS Code the editor shows Play button to be able to run Robot from IDE. However, when using my work project, the Play button is not there.

Example below where Play button is visible. image

Example below where the Play button is not visible.

image

What could cause this issue?

Robot Code plugin is able to find all references to variables and keywords etc. So my assumption is that it's working.

Expected behavior Able to run robot from IDE.

Desktop (please complete the following information):

d-biehl commented 1 year ago

Did you mix Tests and Tasks in one project? If you go to the test explorer:

image

Is there an error message?

jura84 commented 1 year ago

No tasks. Everything is test cases.

It just keeps loading. See number 2 from the picture below.

If you take a look number 1 from the picture it somehow sees this as a test file. image

Any idea where to take a look to figure out what's going on? Any log files anywhere from the plugin etc?

d-biehl commented 1 year ago

Does this happen everytime or just sometimes? What happens if you reload VSCode?

There is an output view (Menu View/Output) on the right side there is a dropdown where you can select the Output for an extension. For RobotCode there are at minumum 2 entries. One for the extension and one for the RobotCode language server.

image

Normally only errors or warnings are shown here. But you can enable more informations by putting the following snippet to you settings.json of your workspace/folder

  "robotcode.languageServer.args": [
    "--debugpy",
    "--log",
    "--log-level",
    "TRACE", // possibilities: CRITICAL, ERROR, WARN, INFO, DEBUG, TRACE
    // "--log-robotframework", // enable logs from RobotFramework language server
    // "--log-language-server", // enable logs from common language server
    // "--log-json-rpc", // enable logs from json-rpc calls
    // "--log-all" // enable logs for everything
  ],
jura84 commented 1 year ago

Plugin started successfully.

image

Seems that there's lock. I saw another bug report for RobotCode related to lock, is this something similar? image

d-biehl commented 1 year ago

Did you set the robotcode.robot.paths setting? Maybe in workspace or in user settings?

Yes lock thing is a known bug, sometimes it hangs, but I am working on it...

jura84 commented 1 year ago

Yes and that seems to solve the issue. However the lock warning still occurs.

image

However I need to add exact path to make it work.

E.g.: C:\folder\folder..

image

Is it possible that plugin search robot test files from workspacefolder automatically? So, using relative path could work in config file.

jura84 commented 1 year ago

I opened the VS Code again and parsing tests based on the paths in settings.json still takes 5mins or so but eventually it finds tests from my project.

Lock warning is still there.. Is this known bug or new one?

image

Also, like commented in previous one.

Is it possible that plugin search robot test files from workspacefolder automatically? So, using relative path defined in config file.

d-biehl commented 1 year ago

If you dont set the robotcode.robot.paths then robotcode looks in the current workspace path, also you can use relative paths here. So normally you don't need the this setting. How big is your workspace, how many *.robot files you have and how many libraries and so? Maybe some testdata files and something. There is another setting where you can exclude directories or files from analysis robotcode.workspace.excludePatterns Maybe this helps?

jura84 commented 1 year ago

"If you dont set the robotcode.robot.paths then robotcode looks in the current workspace path, also you can use relative paths here. So normally you don't need the this setting."

That's good to know and agree how it should be.

"How big is your workspace, how many *.robot files you have and how many libraries and so? Maybe some testdata files and something. There is another setting where you can exclude directories or files from analysis robotcode.workspace.excludePatterns"

In my case I can't exclude anything.

My project is massive compared what I've seen so far...

I have 3 different folders which contains approx 65 folders. Each of those folders contains 1-3 python files. Each Python file contains class with functions to be used from Robot.

I can try to do this without Path settings and let it load 5mins to see if it eventually works.

jura84 commented 1 year ago

Seems that it finds tests cases without robotcode.robot.paths. However, it takes looong time...

d-biehl commented 1 year ago

Do you use remote library or what connects to something that takes longer or so?

If you set the setting robotcode.analysis.progressMode to "detailed" you can see in the statusbar, which file is loaded/analysed, see below.

Maybe it is helpful to find out which file needs more time?.

image image
jura84 commented 1 year ago

It takes time when it goes through the folders and when plugin goes through a robot file which contains resource file import where this resource file is not there.

Same things seem to happen all resource file imports in that file I assume. When I put those files in ignore list then plugin loads way faster.

So, I assume this timeout warning is something to related to that...

jura84 commented 1 year ago

In other words...

We have test files which takes a resource file information based on the --variable argument provided to Robot. All tests are using same variable name, see from example.

Execute example 1: python -m robot --variable RESOURCE_FILE:resources_for_tests.1robot --pythonpath yadayada robot/tests

Execute example 2: python -m robot --variable RESOURCE_FILE:resources_for_tests2.robot --pythonpath yadayada robot/tests

image

This leads to a situation that some tests are only executable using specific resource file. This is our intension and that's why this design is here...

So when settings.json defines certain resource file which is suitable for specific suites then in other suites there are error indicators for not able to import something or missing keywords etc.

Seems that when plugin goes through these files, it takes lot of time. Not sure is it trying to solve these imports by some logic or what?

I assume this based on the information from bottom of the editor where it shows information which file it's going through. At least when it indicates file which I know where imports fails it stays in this file quite long time.

See pic below.

image

d-biehl commented 1 year ago

Sorry, been a little sick the last few days and have not been able to do anything on the computer....

  1. why do you need the ${RESOURCE_FILE} variable? Why do you need to specify the resource imports from outside. Is there another way to do this? Maybe via the --pythonpath setting of Robot?

    The problem here is that each Robot file has its own namespace and each time the analyzer encounters an import statement the import has to be recalculated. Resource files are not simply added to the namespace, but interpreted completely with the namespace of the contained Robot file. And if the resource import also contains variables it takes longer because the variables have to be resolved first.

    I know you can find many examples on the net and also in the documentation of RobotFramework where it is done the same way, so that imports are resolved with variables. But this is not a good style, in most cases also unnecessary, because it adds more complexity to the test case descriptions.

    Maybe there is a way to implement your resource imports differently?

  2. what are the file extensions of your resource files? *.robot or *.resource. The two files are handled differently by RobotFramework, and therefore also by RobotCode. *.resource files must not contain test cases and are therefore not searched for test cases. RobotFramework/RobotCode only looks for *.robot files to find all test cases.

d-biehl commented 1 year ago

any news?

d-biehl commented 1 year ago

@jura84 do you have any new informations for me or can I close this issue?

d-biehl commented 1 year ago

I'm closing this issue as I haven't received any new information in a while. I assume that you have solved the problem. If not, you can reopen it.

jura84 commented 1 year ago

Sorry late reply. Yes this can be closed.

This issue was mainly when we do importing libraries using variables and variable value can be different based on what tests running from test folder.

Also values for these variables are defined as a command prompt argument. When value is something what is not matching with the test content then plugin can't figure out what to import and use.

We will solve this by duplicating test file and defining exact import in test file.

Thank you for your inputs and contribution.