Debug JUnit tests with Eclipse during Maven build

If any JUnit test cases are configured to execute along Maven build, Eclipse won’t automatically debug them. That means even if you mark breakpoints it won’t stop the execution there. We can enable such debugging with a simple goals parameter :

-DforkMode=never test

untitled

Untitled.png

If you are using Maven3 Eclipse plugin, go to Debug configurations, Add a new Maven Build configuration, and add the above goal in the Goals input box. By default, Maven runs tests in a separate process. When you set forkMode option to never, maven plugin will not fork the test process. Hence, while connected to the build process you can debug it. The executions will be stalled at the breakpoints as well.

Happy Coding Guys.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: