title: JUnit test with Maven in a Jenkins plugin
body: <p>I have a problem when I tried to run JUnit tests with Maven. For a Jenkins plug-in I wrote a class for test.  For example: I have the class <code>ConsoleParser</code> in package <em>com.jenkins_plugin</em> in folder <em>src/main/java</em>. The JUnit test case is <code>ConsoleParserTest</code> in <em>package com.jenkins_plugin</em> in folder <em>src/test</em>. For running the JUnit test I added the dependency in the pom:</p>
  
  <pre><code>&lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.11&lt;/version&gt; 
          &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>And I ran in cmd the next command: <code>mvn -Dtest=ConsoleParserTest test</code></p>
  
  <p>The problem is that I've got the following error:</p>
  
  <pre><code>[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
  12:test (default-test) on project swatt_jenkins: No tests were executed!  (Set -
  DfailIfNoTests=false to ignore this error.) -&gt; [Help 1]
  </code></pre>
  
  <p>The full <em>pom.xml</em> is:</p>
  
  <pre><code>&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/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;build&gt;
          &lt;finalName&gt;Jenkins_Plugin&lt;/finalName&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3.2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&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.12&lt;/version&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;emma-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.0-alpha-3&lt;/version&gt;
                  &lt;inherited&gt;true&lt;/inherited&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;process-classes&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;instrument&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.jenkins-ci.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;plugin&lt;/artifactId&gt;
          &lt;version&gt;1.526&lt;/version&gt;
      &lt;/parent&gt;
  
  
      &lt;groupId&gt;Jenkins_Plugin&lt;/groupId&gt;
      &lt;version&gt;1.0&lt;/version&gt;
      &lt;packaging&gt;hpi&lt;/packaging&gt;
  
  
  
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;repo.jenkins-ci.org&lt;/id&gt;
              &lt;url&gt;http://repo.jenkins-ci.org/public/&lt;/url&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
  
      &lt;pluginRepositories&gt;
          &lt;pluginRepository&gt;
              &lt;id&gt;repo.jenkins-ci.org&lt;/id&gt;
              &lt;url&gt;http://repo.jenkins-ci.org/public/&lt;/url&gt;
          &lt;/pluginRepository&gt;
      &lt;/pluginRepositories&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.11&lt;/version&gt; 
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Also, I must mention that with those settings I ran successfully the test but after adding findbugs it crashed. So, I removed findbugs and try to run the test again but the problem that I mentioned appeared. So, can someone explain what I have to do? I tried to add another version of JUnit, Surefire but I had the same problem and I don't understand why.</p>