robotcodedev / robotcode

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

[Question] How to get the configuration from "TESTING"/"Debug Test"? #155

Closed FMode closed 1 year ago

FMode commented 1 year ago

Hello,

My own launch configurations don't work, they startup with lesser options and I don't know how to set them to imitate "TESTING/Debug Test" I always get "[ ERROR ] Expected at least 1 argument, got 0." for my own launch configurations.

Thank you

d-biehl commented 1 year ago

How does your launch configuration look like?

d-biehl commented 1 year ago

What exactly do you want to do? And what does your current config look like?

If you want me to help you, you have to answer!

Maybe you have already solved the problem, then it would be nice to know this, so I can close the issue.

FMode commented 1 year ago

Sorry for the delay. Thanks for your reply. I used yours you posted here (because of the nice verbose): { "name": "RobotCode: Default", "type": "robotcode", "request": "launch", "purpose": "default", "cwd": "${workspaceFolder}", "presentation": { "hidden": false }, "pythonConfiguration": "RobotCode: Python", "attachPython": true, "attachPythonPort": 0, "robotCodeArgs": ["-v"], }, { "name": "RobotCode: Python", "type": "python", "request": "attach", "presentation": { "hidden": true }, "justMyCode": false }

Currently I am editing .vscode\extensions\d-biehl.robotcode-0.53.0\package.json line 1196 and change justMyCode, restart vscode and this works for me....

d-biehl commented 1 year ago

What exactly do you want to do? Only set the debug mode for python? Set variables? Or something similar?

And why do you edit the package.json?

The easiest way is to delete your current launch.json once and then click on the link create launch.json file in the debug view. Then you get a fresh launch.json with the default settings for robotcode.

The entry "RobotCode: Default" are the default settings for the robotcode debugger, here you can enable the Python debugger with the attachPython as you already did. The python configuration to use is set in the property "pythonConfiguration", default is "RobotCode: Python". Below the entry "RobotCode: Python", you can now also set justMyCode to false.

You can create multiple launch configs, the important thing is that you set the purpose property. But only one launch config can be used with the same purpose. The "purpose"="default" determines the base settings for all other launch configs. The "purpose"="test" sets the basic settings for the test execution of VSCode (the play button next to the tests).

For setting variables/environment variables and the like you can use the corresponding properties. However, these are only valid at runtime.

          "variables": {
    "WHAT_EVER_VAR": "whatever value"
},
"env": {
    "WHAT_EVER_ENV_VAR": "whatever value"
},
"args": [
    "--exclude", "wip"
],

The things you set in the launch config are only taken into account during execution.

If you also want to use them in the VSCode editor, then these settings are also available in the normal VSCode settings. Search in the VSCode settings for robotcode.robot. there you will also find the variables, args, paths etc. you should prefer these before you change the launch config.

FMode commented 1 year ago

I am trying to switch "justMyCode".

I guess my problem is that I dont get a Robot Default Config from here? image

d-biehl commented 1 year ago

if there is no "launch.json" and you did not select any debug configuration, and you press F5 or "Start Debugging", vscode tries to find one dependent on the currently active editor tab. If a python file is active then you will get the above list, if a robot file is active then you will get this one:

image

vscode uses then a provided default config, and in this config "justMyCode" is disabled (thats also the case when debugging python files)

just create a "launch.config" as described above.

a minimal "launch.config" with a default configuration for robotcode with python debuger attached and justMyCode disabled can look like this:

{
    "configurations": [
        {
            "name": "RobotCode: Default",
            "type": "robotcode",
            "request": "launch",
            "presentation": {
                "hidden": true
            },
            "purpose": "default",
            "attachPython": true,
            "pythonConfiguration": {
                "justMyCode": true,
            }
        },
    ]
}

ok, there is another way to enable this, without a "launch.config", there are two settings for robotcode robotcode.debug.attachPython and robotcode.debug.defaultConfiguration. just put this in you settings.json:

"robotcode.debug.attachPython": true,
"robotcode.debug.defaultConfiguration": {
    "pythonConfiguration": {
        "justMyCode": false
    }
},

this 2 settings are the base settings for a launch config for robotcode, if you define "launch.config" and in there is a default config for robotcode is defined, these properties are added/overridden to the base config, and if you have select a normal launch config, then these properties are added/overridden.

But by the way, you can also debug tests directly at the tests just do a right click on play button for a test and select debug.

FMode commented 1 year ago

Strange... I used this option before to create the config. But I did not remeber where to access it... I also deleted the launch.json to create a new one before this ticket... Now everything works as expected. Sorry for the inconvience...