views:

499

answers:

2

Hello,

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

A: 

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?

Pascal Thivent
Hi, yes I have but like I said it just displayes the results (again) of the classes the suite runs rather than adding an entry for the suite itself. It seems like surefire report just collects the results from inside the surefire files and lists them rather than caring where they came from.
Coding Monkey
A: 

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.

Tom