Maven Eclipse unit test configuration
Asked Answered
A

1

5

I use Eclipse and for some of my unit tests, I need to set some JVM args for the test to work, -Djava.library.path in particular. I set it in my POM file as follows:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <argLine>-Djava.library.path=target/dll</argLine>
  </configuration>
</plugin>

and it works correctly when I build with Maven. However, when I run in Eclipse (even with the Maven plug-in installed - I have everything else in my Eclipse environment working properly with maven), this JVM argument is not applied. Does anyone know why this is or how to fix this?

Argentum answered 7/7, 2009 at 20:1 Comment(3)
Just to make sure - how are you running the unit test? M2Eclipse? Right-click -> Run as test?Diandre
You might try their mailing lists: [email protected] [email protected] Check those web sites first to see how to join the mailing lists; you have to be a member before you can post.Tawnatawney
Robert, I'm running the test as right click -> run as test. I'll check out the mailing list too, thanks!Argentum
D
7

Running the test in Eclipse with the JUnit test runner does not invoke maven , even if you are using m2eclipse.

I suggest you either:

  • create a maven launch configuration for the test goal;
  • add -Djava.library.path=target/dll to your JVM arguments in the JUnit launch configuration.
Diandre answered 7/7, 2009 at 21:7 Comment(2)
thanks for clarifying. I had done the second option. my worry was that other developers would all have to modify their configs manually - I was hoping to push that out automatically. appreciate the help.Argentum
You can share your run configurations. Run -> Run Configurations -> JUnit -> (select one) -> Common -> Shared file, then check into SCM.Bridget

© 2022 - 2024 — McMap. All rights reserved.