当前位置: 首页 > 知识库问答 >
问题:

通过maven命令提供测试报告名称

陆野
2023-03-14

在我的pom.xml我创建了不同的配置文件烟雾和回归测试使用cucumber框架。使用下面的maven命令运行测试。以下是烟雾测试的例子:

mvn clean test -Psmoke-test -Dcucumber.options="--plugin html:target/cucumber/smoke-test-report.html"

测试运行正常,但即使我提供了-Dcucumber.options,它也不会生成报告。我为cucumber使用了一个常见的运行类,所以我不能将文件名作为@CucumberOptions的一部分注释。

以下是pom.xml配置:

<profile>
        <id>smoke-test</id>
        <properties>
            <test>AutomationTestTrigger</test>
        </properties>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <systemPropertyVariables>
                            <spring.profiles.active>automation-test</spring.profiles.active>
                            <cucumber.filter.tags>@smokeTest</cucumber.filter.tags>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>regression-test</id>
        <properties>
            <test>AutomationTestTrigger</test>
        </properties>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <systemPropertyVariables>
                            <spring.profiles.active>automation-test</spring.profiles.active>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

共有1个答案

杨雪松
2023-03-14

你的POM应该是这样的:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
            <plugin>
            <groupId>net.masterthought</groupId>
            <artifactId>maven-cucumber-reporting</artifactId>
            <version>5.5.0</version>
            <executions>
                <execution>
                <id>execution</id>
                <phase>verify</phase>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <projectName>BDD-Automation</projectName>
                    <outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>
                    <inputDirectory>${project.build.directory}</inputDirectory>
                    <jsonFiles>
                        <param>**/*.json</param>
                    </jsonFiles>
                </configuration>
                </execution>
            </executions>
            </plugin>

和命令,你可以这样使用:mvn test-Dtest=Runner验证

 类似资料:
  • 22.13.7.测试报告 测试任务默认生成以下结果. 一份HTML测试报告 一个与Ant的JUnit测试报告任务兼容的XML.这个格式与许多其他服务兼容,如CI serves 结果是有效的二进制,测试任务会从这些二进制结果生成其他结果。 有一个独立的TestReport任务类型会根据一些Test任务实例生成的二进制源码生成一个HTML报告.使用这种测试类型,需要定义一个destinationDir

  • 当运行单元测试的时候,Gradle 会输出一份 HTML 格式的报告以方便查看结果。Android plugin 则将所有连接设备的测试报告都合并到一个 HTML 格式的报告文件中。所有测试结果都以 XML 文件形式保存到 build/reports/androidTests/ 中(类似于 JUnit 的运行结果保存在 build/reports/tests 中)。可以自定义路径: android

  • 5.4 测试报告 当运行单元测试的时候,Gradle 会生成一份 HTML 报告以便于查看测试结果。 Android plugins 在这个基础上扩展了 HTML 报告,以合并所有已连接设备上的测试结果。 5.4.1 单工程报告 在运行测试的时候工程会自动的生成报告,默认位置是: build/reports/androidTests 这和 jUnit 报告的位置 build/reports/tes

  • 我想使用maven的surefire report插件生成一个报告,它将为我提供所有测试的详细报告,这些测试在每次测试运行期间都会记录日志事件,而不仅仅是测试失败的事件。这也将为我提供测试失败的完整上下文。 这是我的pom.xml文件: 我在这里使用mvn surefire report:report生成报告。所以我想知道我是否可以做其他事情,以便查看测试运行期间发生的详细报告?

  • 在一个配置了多个应用项目和多个 Library 项目的多项目里,当同时运行所有测试的时候,测试结果整合到一份测试报告中可能是非常有用的。 为了实现这个目的,需要在同一个配置中添加另一个插件。可以通过以下方式添加: buildscript { repositories { jcenter() } dependencies { classpath

  • 问题内容: 我听说ReportNG创建的报告比TestNG的常规报告更好。我试图创建ReportNG报告,但失败了。我正在使用Eclipse,并且已经下载ReportNG,并将reportng-1.1.3.jar和velocity- dep-1.4.jar添加到类路径中,并编写了testng-suite.xml,如下所示: 当我执行时,我可以看到TestNG默认报告而不是ReportNG报告。我还