4 Replies Last post: Mar 20, 2012 1:26 AM by Martin Krischik  
Martin Krischik Newbie 12 posts since
Jun 29, 2011
Currently Being Moderated

Mar 19, 2012 4:05 PM

What to do if IntelliJ IDEA fails the make on an unrealted module

Hello,

 

I have a multi module maven setup and would like to execute a unit test for a library module. And here I am a bit stuck because one unrelated modules fails the build. Which leaves me with three options which all kind of suck:

 

  1. If I use IntelliJ IDEA “make” then the unit test is not be executed as the make fails in an module which I don´t actualy care about.
  2. If I use IntelliJ IDEA “Run Maven Goal” then the unit test is only executed when It passes. That is so because Maven will call the unit test as well. Sadly Maven won´t produce a nice output. And you won´t be able to just click and exception stack trace to go to the source code.
  3. I don´t build with IntelliJ IDEA at all but inside a terminal session. That works as expeced but is two steps in different windows.

 

Has anybdoy got an idea how I could improve the workflow.

 

Martin

Mark Vedder Apprentice 915 posts since
Dec 10, 2003
Currently Being Moderated
Mar 19, 2012 4:48 PM in response to: Martin Krischik
Re: What to do if IntelliJ IDEA fails the make on an unrealted module

krischik wrote:

 

2. If I use IntelliJ IDEA “Run Maven Goal” then the unit test is only executed when It passes. That is so because Maven will call the unit test as well. Sadly Maven won´t produce a nice output. And you won´t be able to just click and exception stack trace to go to the source code.

I am not quite understanding this part...  the unit test is only executing when it passes? Can you elaborate on the comment "That is so because Maven will call the unit test as well."  Pass or fail the unit test has to be called to run. Is it a case that the test passes when other tests are run, but fails when run individually? If so, I would humbly submit that you need to correct your unit tests. The issue of its failing may be a bad test and not bad code.

 

Note that you can pass an argument into maven to run just the one test, or a set of tests that match a pattern. See http://maven.apache.org/plugins/maven-surefire-plugin/examples/single-test.html To do this in IDEA, right click the test goal and select "Create 'my-module-name [test]'. In the run configuration dialog, add the switch for the desired test(s).Then run the goal using that Run Configuration via the Run button on the toolbar.

 

As for clicking on the stack trace, you can copy it, then select from the menu Analyze > Analyze Stacktrace... It will by default paste in the contents of the clipboard. (You may need to click normalize) Click OK. You will now have a stacktrace with links. If you do this often, you can map a keyboard shortcut to the 'Analyze Stacktrace' action in File > Settings > IDE Settings > Keymap for quicker access.

 

I hope that helps.

Mark Vedder Apprentice 915 posts since
Dec 10, 2003
Currently Being Moderated
Mar 19, 2012 7:53 PM in response to: Martin Krischik
Re: What to do if IntelliJ IDEA fails the make on an unrealted module

Hello Martin,

 

Sorry, I'm still a bit confused by the part were you say "A «mvn package» will execute all unit tests . . .then IntelliJ IDEA will call them a 2nd time". (I'm not trying to be difficult here; just trying to understand your use case so I can help.) It sounds like you are you running the tests via a IntelliJ IDEA run configuration for the tests that has the "Before Launch" option set to "Run Maven Goal 'some-module:package'. That's the only way I can think of that mvn:package would run, and then IDEA would run the test(s). If so, can you change that goal to "compile" rather  than "package"? (Or use the IDEA make?) That way maven does not run the tests causing the failure.

 

If not, another option would be to try and change the fail setting in the maven configuration. If you go into the Settings for the Maven (click on the wrench & gear icon in the Maven Tool window, or go to File > Settings > Project Settings > Maven), there is a setting for "Multiproject build fail policy". By default, that is set to "Fail Fast". The possible options are:

 

 

  • Fail Fast: At the very first failure, which corresponds to the command line option --fail-fast.
  • Fail At End: Fail at the end, which corresponds to the command line option --fail-at-end.
  • Never Fail: Ignore failures, which corresponds to the command line option --fail-never.

 

 

If you change that to "never fail", that might work to resolve the issue you are having.

 

I hope that helps.

 

-Mark

More Like This

  • Retrieving data ...