maven surefire插件报告空

时间:2015-04-16 10:11:45

标签: maven junit jenkins soapui maven-surefire-plugin

我的要求是通过maven运行多个SOAPUI测试用例,使用jenkins自动构建它并生成测试结果的报告。 除了最后一部分我已经成功完成了。

现在我想生成所有测试用例结果的html报告。 我使用了maven-surefire-report-plugin来实现这一目标。

我已经关注了这篇文章 http://maven.apache.org/surefire/maven-surefire-report-plugin/usage.html 测试用例成功,报告生成成功,但报告中没有记录。

enter image description here

我在这里遗漏了什么吗?是否有任何配置参数来设置生成报告的源路径?

$ {project.build.directory} / site 文件夹中生成surefire报告。 SOAPUI测试用例的输出文件在 $ {project.build.directory} / reports 文件夹中生成。

这是我写的pom.xml

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>soapTest</groupId>
<artifactId>soapTest</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven 2 SoapUI Sample</name>
<url>http://maven.apache.org</url>

<pluginRepositories>
    <pluginRepository>
        <id>SmartBearPluginRepository</id>
        <url>http://www.soapui.org/repository/maven2/</url>
    </pluginRepository>
</pluginRepositories>

<build>
    <plugins>
        <plugin>
            <groupId>com.smartbear.soapui</groupId>
            <artifactId>soapui-maven-plugin</artifactId>
            <version>5.1.2</version>
            <configuration>
                <projectFile>soapui-project.xml</projectFile>
                <outputFolder>${project.build.directory}/test-classes</outputFolder>
                <junitReport>true</junitReport>
                <exportAll>true</exportAll>
                <printReport>true</printReport>
                <testSuite>Authenticate</testSuite>
            </configuration>

            <executions>
                <execution>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

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

    </plugins>
</reporting>

2 个答案:

答案 0 :(得分:3)

Maven Surefire报告插件的第一行 Introduction说:

  

Surefire报告插件解析TEST-*.xml下生成的${basedir}/target/surefire-reports个文件...

因此,如果您将soapui-maven-plugin更改为:

<outputFolder>${basedir}/target/surefire-reports</outputFolder>

这应该有效。

还有additional instructions如何更改maven-surefire-report-plugin的默认位置。

答案 1 :(得分:0)

示例pom.xml,其中还使用mvn site命令创建报告。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.smartbear.samples</groupId>
    <artifactId>soapui-maven-plugin</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Maven 2 SoapUI Sample</name>
    <url>http://maven.apache.org</url>
<pluginRepositories>
    <pluginRepository>
        <id>smartbear-sweden-plugin-repository</id>
        <url>http://www.soapui.org/repository/maven2/</url>
    </pluginRepository>
</pluginRepositories>
    <build>
        <plugins>
            <plugin>
                <groupId>com.smartbear.soapui</groupId>
                <artifactId>soapui-maven-plugin</artifactId>
                <version>5.3.0</version>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <projectFile>globalweather-soapui-project.xml</projectFile>
                            <junitReport>true</junitReport>
                            <outputFolder>${basedir}/target/surefire-reports</outputFolder>
                            <printReport>true</printReport>
                            <exportAll>true</exportAll>
                            <globalProperties>
                                <value>ENV=DEV</value>
                            </globalProperties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
<reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.20.1</version>
        <configuration>
          <outputDirectory>${basedir}/target/surefire-reports</outputDirectory>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>2.1</version>
        <configuration>
          <outputDirectory>${basedir}/target/surefire-reports</outputDirectory>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
</project>