cucumber / docs

Cucumber user documentation
https://cucumber.io/docs/installation/
MIT License
142 stars 516 forks source link

Cucumber is not showing number of scenarios and steps passed or falied #1001

Open nicobonder opened 6 days ago

nicobonder commented 6 days ago

👓 What did you see?

I am following the 10-minute tutorial.

According to the tutorial, I should see:

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

But I am seeing:

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

I can't see how many Scenarios and steps I have and how many passed and failed.

✅ What did you expect to see?

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

I can't see how many Scenarios and steps I have and how many passed and failed.

📦 Which tool/library version are you using?

node v20.14.0 JUnit 5

🔬 How could we reproduce it?

I have this 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>

This is 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"

This is 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);
}
}

And this is the RunCucumberTest.java:

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

public class RunCucumberTest { 
}

When I run mvn test I cant see how many Scenarios and steps I have and how many passed and failed.

📚 Any additional context?

No response

mpkorstanje commented 6 days ago

Ah. Looks like a use case was missed when I made Cucumber quieter by default. Thanks for pointing that out!

For now, you can use the summary plugin to print the summary of executed steps and scenarios. That should make the output mostly as expected. You would use it by changing the @ConfigurationParameter annotation to:

@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty, summary") 
nicobonder commented 6 days ago

Perfect! Now it is working. Thanks!