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.
In the IDE, add debug points where you want the debugger to pause during execution. Then in the terminal, enter your Maven execution command, replacing mvn with mvnDebug . In IntelliJ, make sure your debugging configuration is selected, then press the “Debug” button.
If you don't know why a test fails, you can debug it. In the editor, click the gutter on the line where you want to set a breakpoint. There are different types of breakpoints that you can use depending on where you want to suspend the program. For more information, refer to Breakpoints.
Run testsOpen the Maven tool window. Under the Lifecycle node select test. Note that goals specified in the Maven surefire plugin will be activated at this phase and all tests in a project or in a module will be run.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With