开发者

Maven Surefire reports show multiple class entries rather than a suite

开发者 https://www.devze.com 2022-12-12 05:57 出处:网络
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 seein开发者_Python百科g this:

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 seein开发者_Python百科g 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消