Surefire Unit Test arguments in Maven 2

5 09 2007

To make the surefire plugin to maven2 operate in a seperate jvm instance, and have different jvm args (eg more memory, or profiler) you can change the way in which the unit tests are launched.


Then you will need to set ${maven.test.jvmargs} in the properties area to keep maven going.


and finally to run

mvn  -Dtest=SearchSoak -Dmaven.test.jvmargs='-agentlib:yjpagent -Xmx128m' test

Some time the maven.junit.jvmargs parameter might appear in maven 2 as it did in maven 1 ?




3 responses

4 10 2007

Hi Sakai
your blog seems usefull, i need to knw that sis u try adding some directory to classpath through surefire,like in case when during the tests the testcases need to refer to some file other than test resources?

4 10 2007
Ian Boston

I think you should be able to do a -classpath or something like that, Surefire allows jvm args to be passed through, but I have no idea what it will do to the maven 2 classpath. In general the classpath should be completely defined as maven dependencies. If you need something else, a shell script or bat file makes more sense ?

5 10 2010

Is it possible to configure maven in such a way that a command like mvn test, runs the same test suite multiple times, each time with a different set of configuration arguments?

%d bloggers like this: