Surefire Unit Test arguments in Maven 2

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.


 <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <forkMode>pertest</forkMode>
          <argLine>${maven.test.jvmargs}</argLine>
        </configuration>
      </plugin>
    </plugins>

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


<properties>
	<deploy.target/>
	<maven.test.jvmargs></maven.test.jvmargs>
</properties>

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 ?

Comments

2 Responses to “Surefire Unit Test arguments in Maven 2”

  1. Nisssh on October 4th, 2007 3:38 pm

    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?

  2. Ian Boston on October 4th, 2007 9:41 pm

    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 ?

Leave a Reply




This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a