We are going to show you how to connect to JUnit tests while it is being executed during maven build. We are going to use Eclipse debugger and Eclipse Maven plugin which we were installing here at Maven 3 Eclipse plugin setup post.
When you have Maven3 Plugin Eclipse configured perform these steps to debug JUnit maven test:
1.Click Debug Configurations...
option in the Debug menu
2. Add a new Maven Build
configuration
3. Enter following data:
Name – Name of the build
Base directory – A project that is going to be build
Goals – -DforkMode=never test
Maven is running tests in a separate process by default. By setting forkMode
option to never you tell maven not to fork the test process. This way, while connected to the build process you are able to debug it.
4. Click Debug
button
That’s it. If you have any breakpoints set in your project junit tests code, program execution will stop on them.
The post Maven and JUnit tests debug with Eclipse appeared first on Programmer's lounge.