I've seen this question asked a few places before, but the only
responses that I've seen have been either dead links or links to
reference material that doesn't actually explain the "how" of it.

I have a unit test that connects to a database using a username and
password in a system property as described in the junit docs:
http://junit.sourceforge.net/doc/faq/faq.htm#running_7. I have a line of
code in my test setup that does:

dbusr = System.getProperty("dbusr");

It does the same for the db password and url.

We are using several IDE's and each test runner allows me to define this
property on the command line:

-Ddbusr=foo

However using this switch on the "mvn" command line does not set the
system property when the test is run.

Now I have been able to make this work by specifying the
<systemProperties> element in the pom.xml under the surefire plugin's
configuration. This will pass the hardcoded values from the pom.xml to
the unit test. However, I have not figured out a way to parameterize the
build so that users can supply this information themselves. To date I
have tried the following:

1) Specifying maven.junit.jvmargs=-D... on the command line (in quotes)
as well as in a project.properties file and hardcoded in the pom.xml
itself. This property seems to have no affect regardless of what I do
with it.
2) Specifying the properties themselves on the maven command line, in a
project.properties file.
3) Doing number (2) in conjunction with the maven.junit.sysproperties
set to the names of the properties on the command line, in a
project.properties file.
4) Setting maven.junit.sysproperties hardcoded in the pom.xml as a
system property to the surefire configuration and then setting the
properties themselves as in (2).

None of the 4 approaches above have worked. Has anyone been able to
accomplish this? If so could you describe your approach.

Thank you,

-- Les Walker


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to