Skip to content

Environment Variables not passed to test #222

Closed
@flakobatako

Description

@flakobatako

Edit: I downgraded to v 0.6.0 and worked like a charm. So definitely something messed up my projects in the new release:
image

Prior to the latest extension update all my tests used to behave correctly, they would grab my user's environment variables (i'm on windows 7, 64 bits) whenever I explicitly wanted to (i.e. System.get("MYSQL_FFMA_JDBCURL").

After the extension update, I cannot get my user environment variables anymore (debug only, works normal), but when i want to run or debug a test, no matter how y call them, i'll always get a null.

I read in the changelog that now it supports configuring the env variables via the launch.test.json.

I gave it a shot and configured my env in launch.test.json, like this:
...
"env": {"a":"a"},
...

But after launchig it the problem is still there, my app can't grab any custom environment variable:
image

I tried everything from reinstalling the Extension pack, to restarting the machine.

I don't know if there's something i'm missing in my config, but i swear it worked without any problems yesterday.

Also, I noticed the Test Explorer disapeared.

Steps to reproduce:
-Create new project with unit test (i use the maven extension).
-Add a user environment variable.
-Restart vscode.
-At any rate in the test call the env var like this System.getenv("VARIABLE_NAME")
-Try to debug the test, and step over until we can monitor the variable's value.
-It should be null.
-Configure the test adding the env variable.
-Try to debug the test, and step over until we can monitor the variable's value.
-It should be null.

These are the contents of my launch.test.json

{
"run": {
"default": "",
"items": [
{
"name": "app-ffma-setAppointment",
"projectName": "app-ffma-setAppointment",
"workingDirectory": "c:\Git\Work\Java\gdev-FieldServices\Lambdas\app-ffma-setAppointment",
"args": [],
"vmargs": [],
"env": {
"a": "aaaa"
},
"preLaunchTask": ""
}
]
},
"debug": {
"default": "",
"items": [
{
"name": "app-ffma-setAppointment",
"projectName": "app-ffma-setAppointment",
"workingDirectory": "c:\Git\Work\Java\gdev-FieldServices\Lambdas\app-ffma-setAppointment",
"args": [],
"vmargs": [],
"env": {
"a": "aaaa"
},
"preLaunchTask": ""
}
]
}
}

Thank you in advance.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions