Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment Variables not passed to test #222

Closed
flakobatako opened this issue Jun 27, 2018 · 3 comments · Fixed by #223
Closed

Environment Variables not passed to test #222

flakobatako opened this issue Jun 27, 2018 · 3 comments · Fixed by #223
Assignees
Labels

Comments

@flakobatako
Copy link

flakobatako commented Jun 27, 2018

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.

@ansyral
Copy link
Collaborator

ansyral commented Jun 27, 2018

hi @flakobatako,

  1. Test explorer has been moved to test view container.
    image
  2. I suppose you triggered the test directly from the codelens Run Test? Configuring env variables only works by triggering Run Test with config, which is only visible in the context menu of the test explorer(we kind of removed it from codelens as it make the codelens too long)
  3. You mentioned you used to work, how did you set your env variables? Did you set it manually outside the test run or some way else?

@flakobatako
Copy link
Author

Ok, good to know.

I'll try tomorrow to test it like you say, and yes i tried to run it via code lens.

As for 3, i use to setup my env variables directly in windows via setx command.

Thank you.

@ansyral
Copy link
Collaborator

ansyral commented Jun 27, 2018

@flakobatako I figured out that we have a bug that kind of ignores the environment variables set by process, but before I fix it , you could try the Run with config command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants