Debugging tests of a Maven project in NetBeans

Posted by Lucio Benfante Wed, 20 Feb 2008 10:30:00 GMT

Occasionally I experienced some problems in debugging test classes using NetBeans with Maven projects. Simply, the debugger started but didn’t attach to the running tests.

Eventually I discovered the reason!

I used to configure the surefire plugin with:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <skip>false</skip>
        <useFile>true</useFile>
        <forkMode>once</forkMode> <!-- always, once or never -->
        <!-- <reportFormat>plain</reportFormat> -->
        <argLine>-Xmx512M</argLine>
    </configuration>
</plugin>

The problem is the argLine parameter. It will override the parameters the Mevenide plugin will pass for debugging tests. So, I commented it in my configuration:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <skip>false</skip>
        <useFile>true</useFile>
        <forkMode>once</forkMode> <!-- always, once or never -->
        <!-- <reportFormat>plain</reportFormat> -->
        <!--argLine>-Xmx512M</argLine--> <!-- don't use if you want to debug tests in NetBeans -->
    </configuration>
</plugin>

...and now I can debug my tests!

Posted in ,  | Tags , , ,  | 46 comments