maven-cucumber-reporting 插件没有生成报告 - 没有任何反应

标签 maven cucumber pom.xml

将以下插件添加到我的 pom.xml 时,应该会在我的目标文件夹中生成报告,但什么也没有生成。我的项目只是运行并完成而没有任何报告。有人可以检查一下是否有任何错误吗?

                 <plugin>
                    <groupId>net.masterthought</groupId>
                    <artifactId>maven-cucumber-reporting</artifactId>
                    <version>2.8.0</version>
                    <executions>
                        <execution>
                            <id>execution</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                            <configuration>
                                <projectName>CucumberWebGui</projectName>
                                <outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>
                                <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

最佳答案

由于您没有显示所有配置,我猜您可能会错过 Runner 类中的 plugin 配置。在下面找到一个工作项目。

假设以下结构

pom.xml
src/test/java/TestRunner.java
src/test/java/stepdefs/StepDefinitions.java
src/test/resource/features/demo.feature

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>com.suboptimal</groupId>
    <artifactId>cuke-test.so</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java8</artifactId>
            <version>3.0.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>3.0.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.masterthought</groupId>
                <artifactId>maven-cucumber-reporting</artifactId>
                <version>2.8.0</version>
                <executions>
                    <execution>
                        <id>execution</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <projectName>CucumberWebGui</projectName>
                            <outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>
                            <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

TestRunner.java

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = {"src/test/resource/features"},
        glue = {"stepdefs"},
        plugin = {"json:target/cucumber.json"})
public class TestRunner {
}

StepDefinitions.java

package stepdefs;

import org.junit.Assert;

import cucumber.api.java.en.Given;

public class StepDefinitions {
    @Given("^a successful step$")
    public void aSuccessfulStep() throws Throwable {
        System.out.println("a successful step");
    }

    @Given("^a not successful step$")
    public void aNotSuccessfulStep() throws Throwable {
        System.out.println("a not successful step");
        Assert.fail();
    }
}

演示.feature

Feature: Test cucumber reporting plugin

  Scenario: Run a non failing scenario
    Given a successful step

  Scenario: Run a failing scenario
    Given a not successful step

运行 mvn clean test 将生成 Cucumber 报告文件

target/cucumber.json

运行 mvn verify -DskipTests 将根据 cucumber.json

生成 cucumber-report-html
target/cucumber-report-html/cucumber-html-reports/src-test-resource-features-demo-feature.html
target/cucumber-report-html/cucumber-html-reports/...

运行 mvn clean verify 将一起完成所有操作

关于maven-cucumber-reporting 插件没有生成报告 - 没有任何反应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51257224/

相关文章:

java - 如何使用 Fabric8 docker-maven-plugin 从 Dockerfile 构建 docker 镜像?

java将字符串与变量名匹配并传递变量的值

ruby - 如何使用 capybara + cucumber 断言 ruby​​ 中的 html 表行数

java - 如何将 com.vaadin.ui 导入到 Java 项目

maven - 如何根据依赖关系列出 Maven 构建/编译序列?

java - 类路径已设置,但仍然收到 NoClassDefFoundError

java - 由于缺少 Spring boot 类,WebLogic 12.2.1.2.0 上的部署失败

ruby-on-rails - Webrat 说它找不到一些文本,但文本实际上在那里

java - Eclipse 和 Scala 中的 Maven pom 错误

java - Maven 无法找到 javadoc 命令