Setting environment variable for JUnit to run

6,157 views
Skip to first unread message

Kannan

unread,
Mar 8, 2013, 11:17:18 PM3/8/13
to eclim...@googlegroups.com
In Eclipse, we need to add environment variables to Run configuration so that it gets picked up while running or debugging tests. How do we do that in eclim? When I run a test using :JUnit, it fails because it can't find an environment variable. I have them defined in shell (by exporting them), so Eclipse does not get them.

Eric Van Dewoestine

unread,
Mar 9, 2013, 10:50:22 AM3/9/13
to eclim...@googlegroups.com
I just committed a change[1] to allow you to specify jvm args, system
properties, and environment variables to be supplied to the junit jvm
on a per project basis via the :ProjectSettings command.

Let me know if that provides you with what you need or not.

[1] https://github.com/ervandew/eclim/commit/c24cf9b2cbcf76fc6556d0fc1e1390f01f9a9a78

--
eric

Kannan

unread,
Mar 21, 2013, 2:17:30 AM3/21/13
to eclim...@googlegroups.com
Eric,
  I tried it, but it doesn't seem like the environment variable is getting picked up when running JUnit %. For e.g., I am setting a path like this ...

 org.eclim.java.junit.envvars=["ENV_A=/a/b/c/d", "ENV_B=e/f/g"] 

Any way to troubleshoot?

Eric Van Dewoestine

unread,
Mar 21, 2013, 1:01:49 PM3/21/13
to eclim...@googlegroups.com
On 2013-03-20 23:17:30, Kannan wrote:
> Eric,
> I tried it, but it doesn't seem like the environment variable is getting
> picked up when running JUnit %. For e.g., I am setting a path like this ...
>
> org.eclim.java.junit.envvars=["ENV_A=/a/b/c/d", "ENV_B=e/f/g"]
>
> Any way to troubleshoot?

I tested the functionality by creating a simple test that printed out
the env vars I was passing in:

System.out.println("ENV_A=" + System.getenv("ENV_A"));
System.out.println("ENV_B=" + System.getenv("ENV_B"));

and ran that via :JUnit. Can you replicate the lack of env var
accessibility with a small test case?

> On Friday, March 8, 2013 8:17:18 PM UTC-8, Kannan wrote:
> >
> > In Eclipse, we need to add environment variables to Run configuration so
> > that it gets picked up while running or debugging tests. How do we do that
> > in eclim? When I run a test using :JUnit, it fails because it can't find an
> > environment variable. I have them defined in shell (by exporting them), so
> > Eclipse does not get them.

--
eric

Kannan

unread,
Mar 21, 2013, 2:28:23 PM3/21/13
to eclim...@googlegroups.com
Sorry Eric, I should have done that basic testing before posting. It works now. I had to set the org.eclim.java.junit.jvmargs instead of org.eclim.java.junit.envvars. Can you tell me what the difference is?


On Friday, March 8, 2013 8:17:18 PM UTC-8, Kannan wrote:

Eric Van Dewoestine

unread,
Mar 25, 2013, 10:45:03 AM3/25/13
to eclim...@googlegroups.com
On 2013-03-21 11:28:23, Kannan wrote:
> Sorry Eric, I should have done that basic testing before posting. It works
> now. I had to set the org.eclim.java.junit.jvmargs instead
> of org.eclim.java.junit.envvars. Can you tell me what the difference is?

Basically when creating java the intention was to make the language as
OS agnostic as possible. Environment variables are simply name value
pairs which define info about the current environment in which a
process is running (executable path, current working directory, user
home directory, etc). However their usage can vary a bit from one OS
to another so java system properties where created to provide an OS
independent way to provide the same functionality to a java process.

--
eric
Reply all
Reply to author
Forward
0 new messages