Monday, May 25, 2015

Debugging Maven Project (IntelliJ IDEA)

How to debug your Maven test project?

Well, the command can be found here...
http://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html

But the next question is always... "How can I apply it in my IDE?" It's easy to apply it in command line, but of course, you want to be able to debug your project in an IDE. :)

So we'll use this command and add a configuration in IntelliJ
mvn -DforkCount=0 test

In your IntelliJ go to Run > Edit Configurations
Then add a new maven configuration, by clicking the plus sign in the upper left corner.

There are 4 tabs available: Parameters, General, Runner, and Logs

In Parameters tab:
  • Working Directory: <Is your project directory>
  • Command Line: test
  • Profiles: <blank, unless you have a profile>
Go to Runner tab
  • VM Options: -DforkCount=0
  • JRE: Use the jdk version of your project
Click Apply, then Ok.

After this, you now can debug your Maven test project.

So for other configurations, if you want to add more parameters, you know now where to go and add those parameters. All command of maven should be on Command Line, while parameters goes in parameters tab. ;)
I hope this helps!

No comments:

Post a Comment