【问题标题】:Scalatest html reportsScalatest html 报告
【发布时间】:2012-11-13 22:59:41
【问题描述】:

我正在尝试获取 scalatest 的 html 报告,我发现了很多这样的配置:

<plugin>                                                                                
    <groupId>org.scalatest</groupId>                                                    
    <artifactId>scalatest-maven-plugin</artifactId>                                     
    <version>1.0-M2</version>                                                           
    <configuration>                                                                     
        <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
        <testFailureIgnore>true</testFailureIgnore>                                     
        <filereports>NCXEHLOWFD file/constrained.txt,file/full.txt</filereports>        
        <xmlreports>xml</xmlreports>                                                    
        <htmlreports>html/report.html</htmlreports>                                     
    </configuration>                                                                    
    <executions>                                                                        
        <execution>                                                                     
            <id>test</id>                                                               
            <goals>                                                                     
                <goal>test</goal>                                                       
            </goals>                                                                    
        </execution>                                                                    
    </executions>                                                                       
</plugin>  

但是 IntelliJ 告诉我 xmlreportshtmlreports 是不允许的,并且不会生成 xml 或 html 报告。

任何人都可以提出任何建议吗? 我会很感激的

【问题讨论】:

    标签: html unit-testing scala reporting scalatest


    【解决方案1】:

    您需要使用当前可用的最新插件版本1.0-M4-SNAP1,而不是没有htmlreports 属性的1.0-M2。以下是我的 pom.xml 中的重要部分:

    <project>
        <properties>
            <scala.version>2.9.3</scala.version>
            <scalatest.version>2.0.M5b</scalatest.version>
            <scalatest.plugin.version>1.0-M4-SNAP1</scalatest.plugin.version>
        </properties>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.scalatest</groupId>
                    <artifactId>scalatest-maven-plugin</artifactId>
                    <version>${scalatest.plugin.version}</version>
                    <configuration>
                        <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                        <junitxml>.</junitxml>
                        <filereports>WDF TestSuite.txt</filereports>
                        <htmlreporters>${project.build.directory}/html/scalatest</htmlreporters>
                        <testFailureIgnore>false</testFailureIgnore>
                    </configuration>
                    <executions>
                        <execution>
                            <id>test</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    
        <dependencies>
            <dependency>
                <groupId>org.scala-lang</groupId>
                <artifactId>scala-library</artifactId>
                <version>${scala.version}</version>
            </dependency>
    
            <dependency>
                <groupId>org.scalatest</groupId>
                <artifactId>scalatest_${scala.version}</artifactId>
                <version>${scalatest.version}</version>
                <scope>test</scope>
            </dependency>
            <!-- required by scalatest-maven-plugin to generate HTML report -->
            <dependency>
                <groupId>org.pegdown</groupId>
                <artifactId>pegdown</artifactId>
                <version>1.2.1</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </project>
    

    有了这个设置,我可以运行mvn clean install,它会在${project.build.directory}/html/scalatest下生成漂亮的HTML报告

    【讨论】:

    • 您可能需要添加另一个依赖项:com.vladsch.flexmark:flexmark-all:0.35.10
    【解决方案2】:

    @rozky 的解决方案对我有用,但 css 很尴尬。它不能正确显示表格。无论我使用什么版本的 pegdown 和 scalatest-maven-plugin,它都不会在表中显示套件名称列:/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-22
      • 1970-01-01
      • 1970-01-01
      • 2016-08-31
      • 2013-09-14
      • 1970-01-01
      • 2020-02-17
      • 2019-08-14
      相关资源
      最近更新 更多