I've inherited a Maven project that includes a large number of unit tests and integration tests. I added a unit test for a change I've made. However, this unit test is failing and so are a number of integration tests (because they rely on a specific environment). I want to debug my unit test (and the method under test), but when I right-click on the test method and choose "debug", IntelliJ IDEA does a "Build" first, and that's the Maven build which tries to execute all tests and integration tests. As a result, the build fails and I can't therefore debug my unit test. How can I get around this?
Intellij has specific configuration for the builds. The default configuration is the "build" command which will build the project.
You can change this command into a maven command so you will manually skip the tests
to do that click edit configuration and go to the profile configuration you want to change. :
At the very bottom you can see the before launch part :
from there you remove the previous with the ( - ) and you click the ( + ) to add a new one. Scroll down in the list to find the maven goal
once you check it you have to add the manual command there. Note: You dont need to write mvn as its ommited.
An other approach you can follow is to instruct intellij to use maven for all of its actions by delegating everything to maven. to do that just go to the settings and follow the path :
Build,Execution,Deployment -> Build Tools > Maven > Runner
and check the Delegate IDE build/run actions to Maven.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.