I am trying to debug Maven tests in IntelliJ IDEA. When I open IDEA's Maven Projects view and right-click on test goal, I get an option to debug it. Clicking it executes this goal but the execution never stops at any breakpoints. What am I missing?
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.
Manage breakpoints To do this, go to Settings/Preferences | Build, Execution, Deployment | Debugger and select Drag to the editor or click with middle mouse button. Clicking a breakpoint will then enable or disable it.
To solve this, simply remove the jar of the debugged module from all modules' dependencies in the Project Structure. If you do not know which modules have the debugged module jar as dependencies, you can use some tools (Eg. Sublime Text, bash, ...) to search for the module name which is stored in Intellij *.
Debug failed tests 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.
Just disable the forked mode - something like this in your pom file (under project/build/plugins section):
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.14</version> <configuration> <forkMode>never</forkMode> </configuration> </plugin>
One solution would be to use remote debugging:
configure the surefire plugin: <debugForkedProcess>true</debugForkedProcess>
;
run the test (will wait for a remote debugger to connect)
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