Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nicobonder opened this issue Jun 25, 2024 · 2 comments
Open

Comments

@nicobonder
Copy link

nicobonder commented Jun 25, 2024

👓 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
Copy link
Contributor

mpkorstanje commented Jun 25, 2024

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
Copy link
Author

Perfect! Now it is working. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants