Adams Bros Blog

9Jul/110

Maven Test Debug Mode Profile

I should have blogged about this long ago, as I feel that this is a very useful way of debugging unit tests with maven.  This is especially so if you're primarily a command line sort of guy like myself.

All that is required to be able to debug a unit test is

  1. configure the maven surefire plugin from within a profile
  2. activate the maven profile from the command line

The following XML profiles section will work just peachy for you.

  
 <profiles>
    <profile>
      <id>dtest</id>
      <properties>
        <maven.test.skip>false</maven.test.skip>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.5</version>
            <configuration>
              <forkMode>once</forkMode>
              <debugForkedProcess>true</debugForkedProcess>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

Now just run this.

  mvn -Pdtest package
Filed under: Java Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

 

No trackbacks yet.