【问题标题】:maven sure-fire plugin report emptymaven sure-fire 插件报告为空
【发布时间】:2015-06-22 16:12:53
【问题描述】:

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

现在我想生成所有测试用例结果的 html 报告。 我使用 maven-surefire-report-plugin 这样做。

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

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

surefire 报告在 ${project.build.directory}/site 文件夹中生成。 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>

【问题讨论】:

  • 你是如何在 jenkins 中启用万无一失的报告的?我添加了surefire插件,但报告仍然使用基本的junit报告而不是surefire报告

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


【解决方案1】:

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

Surefire Report Plugin 解析TEST-*.xml 下生成的TEST-*.xml 文件...

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

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

应该可以的。

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

【讨论】:

  • 我昨天做了这个更改,可以运行测试并成功获取报告。谢谢! :)
【解决方案2】:

使用 mvn site 命令创建报告的示例 pom.xml。

<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>

【讨论】:

    猜你喜欢
    • 2023-03-21
    • 1970-01-01
    • 2018-01-29
    • 1970-01-01
    • 1970-01-01
    • 2010-11-19
    • 2022-01-23
    • 2017-03-12
    • 2016-01-03
    相关资源
    最近更新 更多