是否有一个Maven的体面HTML

是否有一个Maven的体面HTML

本文介绍了是否有一个Maven的体面HTML Junit的报告插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得万无一失的报表插件非常不适合我的工作作风。我清理项目的所有时间,我不想花5分钟,我想看看我的浏览器测试报告每次来重建整个网站。如果键入MVN神火-报告:报告只,生成的报告是太丑陋了,勉强可读。我正在寻找的是类似蚂蚁的JUnitReport任务。是否有一个可用在那里了吗?

I find the surefire-report plug-in very unsuitable to my working style. I clean the project all the time and I don't want to spend 5 min to rebuild the whole site every time I want to look at the test report in my browser. If I type mvn surefire-report:report-only, the generated report is too ugly and barely readable. What I'm looking for is something like ant's JUnitReport task. Is there one available out there already?

推荐答案

事实上,在每个构建生成整个网站显然不是一个选项。但问题是, MVN神火-报告:报告只不创建的CSS / * css文件,因此丑陋的结果。这是记录在(并不意味着什么,虽然会发生) 。就个人而言,我不使用HTML报告说,多让我可以忍受,但是,这不是一个很好的答案所以这里是一个基于蚂蚁任务的解决方法(*叹*):

Indeed, generating the whole site at each build is clearly not an option. But the problem is that mvn surefire-report:report-only doesn't create the the css/*.css files, hence the ugly result. This is logged in SUREFIRE-616 (doesn't mean something will happen though). Personally, I don't use HTML reports that much so I can live with that but that's not a good answer so here is a workaround based on the ant task (*sigh*):

  <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
      <execution>
        <id>test-reports</id>
        <phase>test</phase>
        <configuration>
          <tasks>
            <junitreport todir="target/surefire-reports">
              <fileset dir="target/surefire-reports">
                <include name="**/*.xml"/>
              </fileset>
              <report format="noframes" todir="target/surefire-reports"/>
            </junitreport>
          </tasks>
        </configuration>
        <goals>
          <goal>run</goal>
        </goals>
      </execution>
    </executions>
    <dependencies>
      <dependency>
        <groupId>ant</groupId>
        <artifactId>ant-junit</artifactId>
        <version>1.6.2</version>
      </dependency>
    </dependencies>
  </plugin>

更新:我最初的想法是运行的按需来生成报告Maven的AntRun插件...但是这不是我贴,我把它绑定到测试阶段......但我没想到失败的测试的情况下(即会停止构建和prevent的AntRun插件的执行)。所以,无论是:

Update: My initial idea was to run the Maven AntRun plugin "on demand" to generate the reports... but that's not what I posted, I bound it to the test phase... But I didn't think about the case of failed tests (that would stop the build and prevent the execution of the AntRun plugin). So, either:


  1. 不要绑定AntRun插件的测试阶段,移动执行外配置并调用 MVN antrun:运行在命令行上想何时生成报告。

  1. Don't bind the AntRun plugin to the test phase, move the configuration outside the execution and call mvn antrun:run on the command line to generate the reports when wanted.

或使用测试魔力的选项并将其设置为true,在神火插件配置:

or use the testFailureIgnore option of the test mojo and set it to true in the surefire plugin configuration:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <testFailureIgnore>true</testFailureIgnore>
  </configuration>
</plugin>


  • 或设置在命令行中使用-D参数这个前pression:

  • or set this expression from the command line using the -D parameter:

    $ mvn test -Dmaven.test.failure.ignore=true
    


  • 我认为,方案1是最好的选择,你不一定要生成的报告(特别是当测试通过),并生成它们可以系统地构建减慢长远。我想他们产生需求。

    I think that Option #1 is the best option, you don't necessarily want to generate the reports (especially when the test passes) and generate them systematically may slow down the build on the long term. I'd generate them "on demand".

    这篇关于是否有一个Maven的体面HTML Junit的报告插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    07-29 19:47