2012-11-26 87 views
2

我試圖讓scalatest的HTML報告,我發現了很多配置是這樣的: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報告。

任何人都可以提出任何建議嗎? 我會很感激

回答

7

您需要使用現有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,它會${project.build.directory}/html/scalatest

下產生很好的HTML報告