2010-12-10 73 views
1

我在獲取生成的站點中出現surefire報告時遇到了一些困難。我運行mvn clean site:site,報告丟失。從生成的站點丟失的Maven Surefire報告

我的pom.xml如下: -

<?xml version="1.0" encoding="UTF-8"?> 
<project> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>testMaven</groupId> 
    <artifactId>testMaven</artifactId> 
    <name>Test Maven Project</name> 
    <version>1.0</version> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.8.1</version> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.6</version> 
      </plugin> 
     </plugins> 
    </build> 

    <reporting> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.6</version> 
      </plugin> 
     </plugins> 

    </reporting> 
</project> 

當我做MVN測試,測試運行良好。

$ mvn clean test 
[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building Test Maven Project 
[INFO] task-segment: [clean, test] 
[INFO] ------------------------------------------------------------------------ 
[INFO] [clean:clean {execution: default-clean}] 
[INFO] Deleting directory c:\workspace\java\rsa\testMaven\target 
[INFO] [resources:resources {execution: default-resources}] 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] Copying 0 resource 
[INFO] [compiler:compile {execution: default-compile}] 
[INFO] Compiling 1 source file to c:\workspace\java\rsa\testMaven\target\classes 
[INFO] [resources:testResources {execution: default-testResources}] 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] Copying 0 resource 
[INFO] [compiler:testCompile {execution: default-testCompile}] 
[INFO] Compiling 1 source file to c:\workspace\java\rsa\testMaven\target\test-classes 
[INFO] [surefire:test {execution: default-test}] 
[INFO] Surefire report directory: c:\workspace\java\rsa\testMaven\target\surefire-reports 

------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 
Running testMaven.main.HelloWorldServiceTest 
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 sec 

Results : 

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 

[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESSFUL 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 1 second 
[INFO] Finished at: Fri Dec 10 10:42:20 CST 2010 
[INFO] Final Memory: 17M/1016M 
[INFO] ------------------------------------------------------------------------ 

我可以知道我在做什麼錯嗎?謝謝。

回答

4

您需要在報告部分使用maven-surefire-report-plugin(而不是maven-surefire-plugin),例如,

<reporting> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-report-plugin</artifactId> 
      <version>2.6</version> 
     </plugin> 
    </plugins> 
</reporting> 
相關問題