Debugging Maven Unit Test

I don’t trust debugging Maven unit tests straight using Eclipse’s JUnit plugin, sometime it’s buggy and the classpath don’t match with Maven.

Here’s how you can attach eclipse debugger straight from Maven process. First setup few breakpoints of the suspicious code as per normal, and setup a Maven run configuration like this:

maven-debug-runconfig

When you run this configuration, Maven will halt right before unit tests are run:

maven-debug-console

Now create a Remote Java Application Debug configuration pointing to localhost port 5050

maven-debug-debugconfig

Happy debugging!

Leave a Reply