Cucumber 未显示场景数量以及通过或失败的步骤

问题描述 投票:0回答:1

`我正在学习黄瓜。我正在遵循 10 分钟教程。

根据教程,我应该看到: 失败场景:

hellocucumber/is_it_friday_yet.feature:4 # Sunday isn't Friday
1 Scenarios (1 failed)3 Steps (1 failed, 2 passed)

但我看到:

[ERROR] Failures:[ERROR]   expected: <Nope> but was: <null>[INFO][ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

我看不到我有多少个场景和步骤,以及有多少通过和失败。

我有这个pom:

`<?xml version="1.0" encoding="UTF-8"?><project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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>hellocucumber</groupId>
<artifactId>hellocucumber</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

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

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-bom</artifactId>
            <version>7.18.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.junit</groupId>
            <artifactId>junit-bom</artifactId>
            <version>5.10.2</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit-platform-engine</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-suite</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.13.0</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.2.5</version>
        </plugin>
    </plugins>
</build>
</project>

这是 is_it_friday_yet.feature:

`Feature: Is it Friday yet?Everybody wants to know when it's Friday
Scenario: Sunday isn't FridayGiven today is SundayWhen I ask whether it's Friday yetThen I should be told "Nope"`

这是 Stepdefs.java:

package hellocucumber;
import io.cucumber.java.en.*;
import static org.junit.jupiter.api.Assertions.assertEquals;

class IsItFriday {static String isItFriday(String today) 
{return null;}
}

public class Stepdefs {private String today;private String actualAnswer;
@Given("today is Sunday")
public void today_is_Sunday() {
    today = "Sunday";
}

@When("I ask whether it's Friday yet")
public void i_ask_whether_it_s_Friday_yet() {
    actualAnswer = IsItFriday.isItFriday(today);
}

@Then("I should be told {string}")
public void i_should_be_told(String expectedAnswer) {
    assertEquals(expectedAnswer, actualAnswer);
}
}

这是 RunCucumberTest.java:

@Suite @IncludeEngines("cucumber") 
@SelectPackages("hellocucumber") 
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty") 

public class RunCucumberTest { 
}

当我运行 mvn test 时,我看不到我有多少场景和步骤,以及有多少通过和失败。

testing cucumber bdd
1个回答
0
投票

我从 Cucumber 的人那里得到了答案。需要添加摘要插件来打印执行步骤和场景的摘要。在 RunCucumberTest.java 中应该是: @ConfigurationParameter(键= PLUGIN_PROPERTY_NAME,值=“漂亮,摘要”)

© www.soinside.com 2019 - 2024. All rights reserved.