unit-testingmaven-2junitintellij-idea

IntelliJ IDEA debugger skips breakpoints when debugging Maven tests


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?

EDIT: I realized (a decade ago 😅) it is infinitely easier to run the tests via IntelliJ (right-click on the src/test/java directory and Run Tests) and call it a day then to run them via Maven and wrangle with the debugger. I highly recommend you do the same and forget this whole thing.


Solution

  • One solution would be to use remote debugging:

    1. configure the surefire plugin: <debugForkedProcess>true</debugForkedProcess>;

    2. run the test (will wait for a remote debugger to connect)

    3. create and run a remote debug configuration in IntelliJ (will hit your breakpoint); the port to connect to is 5005.