wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven: Anyone know how to auto-include this option when I'm running tests? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven: Anyone know how to auto-include this option when I Watch "Maven: Anyone know how to auto-include this option when I New topic
Author

Maven: Anyone know how to auto-include this option when I'm running tests?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi,

I'm using Maven 1.1 for a Java (1.5) project on Mac 10.5.6. I have a number of unit tests within a sub-folder of my "test" directory. In order to run everything smoothly, I must run a command like below when I cd into my test directory:

maven -Dhttp.nonProxyHosts=localhost test:test

My question is, do you know a file or somewhere I can place the "-Dhttp.nonProxyHosts=localhost" option so I can just run "maven test:test"? When I pass this project on to another developer, I don't want to have to explicitly tell them to include this option.

Thanks, - Dave
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Hi Dave,

I'm not really sure if this is what you want, but I'm actually using TestNG for unit tests together with the JMockit framework. This requires a command line option you would usually add on the console just like in your example. I have not tested it but I could imagine that you can use the <argline> tag to define a system property with <argline>-Dhttp.nonProxyHosts=localhost</argline>:



Btw. just in case you don't know: The surefire plugin is usually use by maven to run tests! So it should be the right place to add the said command line options which are only required during the test phase! I hope this helps. I'd like to hear your feedback in any case!

Marco
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Thanks for this reply, Marco. What complicates things is that I'm restricted to an old version of Maven -- 1.1. I was looking at the surefire plugin and it appears to only be available for Maven 2 and higher. Perhaps I'm misunderstanding, but if I'm not, do you know any solution that would be backwards compatible with Maven 1.1?

All the best, - Dave
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Sorry Dave, I've only used Maven since 2.x and I've no idea how things work in Maven 1.x...

The only thing I can think of which COULD work even for Maven 1 would be the Maven environment variable which is in your case MAVEN_OPTS if I remember correctly. Depending on your OS, i.e. Linux or Windows, it should be possible to add something like this in UNIX/Linux:

to the environment of the user which runs your Maven project. I'm really not sure but it could work...

Marco
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Maven: Anyone know how to auto-include this option when I'm running tests?
 
Similar Threads
Maven: Why is my test ignoring project.properties ?
"maven site" fails on tests, while "maven test" runs without failures
Question about JWebUnit / maven
Where to place Selenium tests in separate maven project
maven and Junit Tests