English 中文(简体)
Maven Surefire reports show multiple class entries rather than a suite
原标题:

I ve been asked to configure Maven s surefire report generator to include one entry for the test suite which in turn tests classes A,B and C but instead of seeing this: A B C MySuite I see this A B C A B C

So there s two problems really: 1) How do I stop the tests running twice. 2) How do I get the report to show me one entry per class or suite.

You might ask why is this so important, the answer is the Architect wants to see one test which encompases the whole component and shows one entry in the report for it and I don t want tests to run twice, (or even more) times.

Thanks and regards,

CM

问题回答

To answer your first question, please note that there is a Surefire build and reporting plugin. Therefore when nested within both, the build and reporting elements, it will naturally run twice. You can avoid this by using the report-only goal in your reporting element:

 <project>
   ...
   <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.4.3</version>
        <configuration>
          <includes>
            <include>test/my/Suite.java</include>
          </includes>
          <excludes>
            <exclude>test/my/NoTestClass.java</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.4.3</version>
        <reportSets>
          <reportSet>
            <reports>
              <report>report-only</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>
  ...
</project>

With respect to your second question, it might come down to the test framework you use and how your test cases are designed. More details are needed to answer this part of the question.

Did you specify your test suite in the surefire configuration with something like this:

<includes>
  <include>**/AppTestSuite.java</include>
</includes>

What does the report looks like with this configuration?





相关问题
Derby gets stuck closing?

I ve got unit tests (in maven) that use derby. At the end of the test run, there is a very long pause, with these log messages before the pause. INFO: Closing Hibernate SessionFactory Nov 16, 2009 8:...

Execute goal on parent after children complete

I have a multi-module maven project (several levels of nesting). Normally, when I execute a maven build (like mvn install or whatever), maven will run all the goals for the parent project before ...

Including dependencies in a jar with Maven

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file? I have a project the builds into a single jar file. I want the classes from dependencies to be copied into ...

Java Equivalent of distcc

Distcc makes it easy to distribute a C or C++ compile job across a number of machines, and is a godsend for working with large, frequently-built codebases. An increasing number of our large projects ...

Maven Assembly Problem

I have a maven multiple-module project, which is giving me headaches in the assembly:assembly phase. I have a module which has an assembly defined in it which works fine when I invoke mvn assembly:...

热门标签