3

我正在尝试获取 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 告诉我这是不允许的,并且不会生成 xml 或 html 报告xmlreportshtmlreports

任何人都可以提出任何建议吗?我会非常感谢

4

2 回答 2

9

您需要使用当前可用的最新插件版本1.0-M4-SNAP1,而1.0-M2不是没有htmlreports属性。以下是我的 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它,它会在下面生成漂亮的 HTML 报告${project.build.directory}/html/scalatest

于 2013-03-07T19:08:28.943 回答
2

在此处输入图像描述

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

于 2019-05-09T11:17:38.430 回答