10
votes

I'm working with a multi-artifact Maven project where artifacts in the project have a few dependencies on each other. I am using IntelliJ 9. I'd like to be able to set breakpoints in my unit tests, but when I right-click on the unit tests folder for my artifact and choose "Debug 'All Tests'", I get a Class not found exception referring to a class in a separate Maven artifact.

I can run the Maven "test" goal on the parent artifact and it works fine.

Any ideas? Thanks.

2

2 Answers

15
votes

In you run Maven from command line, you will be able to run it with debugger enabled and just attach Idea as remote debugger. That's how I usually use it.

mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE" test

See http://maven.apache.org/plugins/maven-surefire-plugin/examples/debugging.html

This will allow debugger connection to port 8000 and wait for you to attach before execution.

3
votes

I wanted to run the unit tests for a specific package.

I was able to get this to work by making a new JUnit run/debug configuration in IntelliJ. I told it to run the tests in the specific package and for "Use classpath and JDK of module", I picked the root Maven artifact.