title: How to stop a maven build, if a junit test fails?
body: <p>I have set up a maven project, which is create a JAR File as artefact. Now I have created some JUnit tests and would like to stop the maven build, if one of these junit test fails. What steps are necessary, to do this? Now I get a JAR File, although one or more JUnit test fails.</p>
  
  <p>I have created my JUnit test in the folder "src/main/resources" und here is the build  snippet of my pom.xml:</p>
  
  <pre><code>    &lt;plugins&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.0.2&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;optimize&gt;true&lt;/optimize&gt;
                  &lt;fork&gt;true&lt;/fork&gt;
                  &lt;source&gt;${source.jdk}&lt;/source&gt;
                  &lt;target&gt;${target.jdk}&lt;/target&gt;                  
              &lt;/configuration&gt;
          &lt;/plugin&gt;   
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;descriptorRefs&gt;
                      &lt;descriptorRef&gt;
                          jar-with-dependencies
                      &lt;/descriptorRef&gt;
                  &lt;/descriptorRefs&gt;
                  &lt;archive&gt;
                      &lt;addMavenDescriptor&gt;false&lt;/addMavenDescriptor&gt;                      
                      &lt;manifestEntries&gt;
                          &lt;Source-JDK&gt;${source.jdk}&lt;/Source-JDK&gt;
                          &lt;Target-JDK&gt;${target.jdk}&lt;/Target-JDK&gt;                                      
                          &lt;Project-Build-SourceEncoding&gt;${project.build.sourceEncoding}&lt;/Project-Build-SourceEncoding&gt;    
                          &lt;Maven-Build-Timestamp&gt;${maven.build.timestamp}&lt;/Maven-Build-Timestamp&gt;
                      &lt;/manifestEntries&gt;
                      &lt;manifest&gt;  
                          &lt;addDefaultImplementationEntries&gt;true&lt;/addDefaultImplementationEntries&gt;
                          &lt;addDefaultSpecificationEntries&gt;true&lt;/addDefaultSpecificationEntries&gt;                       
                          &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                          &lt;classpathPrefix&gt;lib/&lt;/classpathPrefix&gt;
                          &lt;mainClass&gt;${project.groupId}.${project.artifactId}.myMainFile&lt;/mainClass&gt;
                      &lt;/manifest&gt;
                  &lt;/archive&gt;
                  &lt;appendAssemblyId&gt;false&lt;/appendAssemblyId&gt;
                  &lt;classifier&gt;jar-with-dependencies&lt;/classifier&gt;
              &lt;/configuration&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;assembly-jar-Id&lt;/id&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;single&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>