title: Maven running tests annotated with junit @Ignore when building Java project
body: <p>I've annotated a bad test with @Ignore, both on the method-level and on the class level. When running the test through the command line (I've tried "mvn clean install", "mvn test", "mvn clean install -DskipTests; mvn test"), however, the @Ignore annotation is ignored, the test is run, and- as it is a bad test- it fails. </p>
  
  <p>Here is the test:</p>
  
  <pre><code>public class UserTest extends PersistentTestBase {
      @Test
      @Ignore
      public void testPersistence() {
      ...
      }
  }
  </code></pre>
  
  <p>And here is my pom.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
  ...
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  
  ...
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
     ...
  
      &lt;!-- Testing --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.12&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.jmock&lt;/groupId&gt;
          &lt;artifactId&gt;jmock-junit4&lt;/artifactId&gt;
          &lt;version&gt;2.8.1&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.jmock&lt;/groupId&gt;
          &lt;artifactId&gt;jmock-legacy&lt;/artifactId&gt;
          &lt;version&gt;2.8.1&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.easymock&lt;/groupId&gt;
          &lt;artifactId&gt;easymock&lt;/artifactId&gt;
          &lt;version&gt;3.4&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  ...
  
  &lt;!-- For dep management, see Mykong.com's "How to create a jar file with Maven" --&gt;
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;!-- Necessary to force language level of Java 8 --&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;3.2&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;${java.version}&lt;/source&gt;
                  &lt;target&gt;${java.version}&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-surefire-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.18.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;junitArtifactName&gt;junit:junit-dep&lt;/junitArtifactName&gt;
                  &lt;useFile&gt;false&lt;/useFile&gt;
                  &lt;trimStackTrace&gt;false&lt;/trimStackTrace&gt;
                  &lt;reuseForks&gt;false&lt;/reuseForks&gt;
                  &lt;forkCount&gt;1&lt;/forkCount&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
          &lt;!-- Packages into a jar, looking for deps in target/dependency-jars --&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;excludes&gt;
                      &lt;exclude&gt;**/log4j.properties&lt;/exclude&gt;
                  &lt;/excludes&gt;
                  &lt;archive&gt;
                      &lt;manifest&gt;
                          &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                          &lt;mainClass&gt;...Application&lt;/mainClass&gt;
                          &lt;classpathPrefix&gt;dependency-jars&lt;/classpathPrefix&gt;
                      &lt;/manifest&gt;
                  &lt;/archive&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
          &lt;!-- Moves all compiled deps to target/dependency-jars --&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.5.1&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;copy-dependencies&lt;/id&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;copy-dependencies&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;includeScope&gt;runtime&lt;/includeScope&gt;
                          &lt;outputDirectory&gt;${project.build.directory}/dependency-jars&lt;/outputDirectory&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;mainClass&gt;...Application&lt;/mainClass&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p>Worth noting that the test is skipping when the class is run in Intellij IDEA 14, and that there are some other issues with tests failing on mvn test that are passing in Intellij (but are out of the scope of this question). Thank you for the help!</p>