title: Maven: How to run some tests after the "install" phase, during a "release:prepare"?
body: <p>I have some complex tests that use <em>standalone Maven projects</em> to validate some code. Those Maven projects are programatically packaged by the tests and the resulting <code>.jar</code> files are then used. Those projects use artifacts from my main multi-modules project <em>at the current version</em>, in their <code>pom.xml</code>. In other words, the test Maven projects need to be able to find artifacts provided by my main project.</p>
  
  <p>In an IDE, everything works fine since the current artifacts from my main project are resolved dynamically (no local repository required) when I run the tests. Also, I can install those SNAPSHOT versions before running the tests. But when I want to release a new version of my project, I would need <code>release:prepare</code> to:</p>
  
  <ul>
  <li>Update the versions (remove all the "-SNAPSHOT").</li>
  <li>Runs all tests that do not end with <code>*.PostInstallTest.java</code>.</li>
  <li>Package the artifacts and <em>install them</em> locally.</li>
  <li>THEN runs the tests that end with <code>*.PostInstallTest.java</code>, since those tests require access to the previously installed artifacts! If the tests fail, no commits would by pushed by <code>release:prepare</code>.</li>
  </ul>
  
  <p>I know this is not perfect since a "bad" version of the artifacts could be installed locally, when the "PostInstallTest" tests fail. But I would prefere that to not having those tests run at all!</p>
  
  <p>Currently, my only working idea is to set an system property when the <code>release</code> profile is used, and have the <code>*.PostInstallTest.java</code> files disable themselves if that property exists. That way, those tests would still work when ran inside my IDE (without the <code>release</code> profile), but wouldn't be executed at all during a <code>release:prepare</code> command. But, again, I would like them to be executed.</p>
  
  <p>I looked at the <a href="http://maven.apache.org/maven-release/maven-release-plugin/examples/run-goals-before-commit.html" rel="nofollow noreferrer">preparationGoals</a> configuration of the Maven Release Plugin but I'm not sure how it could help me. I also looked at the <a href="https://maven.apache.org/surefire/maven-failsafe-plugin/" rel="nofollow noreferrer">Maven Failsafe Plugin</a> but it doesn't seem to support the "install" phase.</p>
  
  <p><strong>So, my question</strong>: Is there a way to run some tests <em>after</em> the "install" phase, when <code>release:prepare</code> is used (or <em>at</em> the "install" phase, but after the default plugin)?</p>
  
  <p>UPDATE: Here's a quick schema, if it can help understand what's going on:</p>
  
  <p><a href="https://i.stack.imgur.com/Gjw9D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gjw9D.png" alt="enter image description here"></a></p>
  
  <p><strong>UPDATE 2</strong>: I didn't test Failsafe properly, after all. It does work at the "install" phase! Look at df778899's answer.</p>