Serenity Cucumber-JVM - Incorrect Match between Runner & Scenario Step

380 views
Skip to first unread message

Andy Suruceanu

unread,
Mar 1, 2015, 4:57:25 AM3/1/15
to thucydid...@googlegroups.com
Hi there,

Have anyone encountered such exception below while executing the Cucumber Serenity (e.g. @RunWith(CucumberWithSerenity)) tests ?

cucumber.runtime.CucumberException: Expected step: "I want to purchase <amount> widgets" got step: "I want to purchase 6 widgets"
at cucumber.runtime.junit.JUnitReporter.fetchAndCheckRunnerStep(JUnitReporter.java:71)
at cucumber.runtime.junit.JUnitReporter.match(JUnitReporter.java:61)
at cucumber.runtime.Runtime.runStep(Runtime.java:277)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:48)
at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:91)
at org.junit.runners.Suite.runChild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)

private Step fetchAndCheckRunnerStep() {
    Step scenarioStep = (Step)this.steps.remove(0);
    Step runnerStep = (Step)this.executionUnitRunner.getRunnerSteps().remove(0);
    if(!scenarioStep.getName().equals(runnerStep.getName())) {
        throw new CucumberException("Expected step: \"" + scenarioStep.getName() + "\" got step: \"" + runnerStep.getName() + "\"");
    } else {
        return runnerStep;

    }}

Would anyone suggest what's wrong? I've noticed that if there are 2 Scenario Outline in one feature file, the second scenario outline is failing with the above error.

Versions:

Serenity-Core: 1.0.35

Serenity-Cucumber: 1.0.8

JUnit version: 4.11

Intellij IDEA:14.0.3

Thanks in advance!

Andy




Andy Suruceanu

unread,
Mar 16, 2015, 6:49:01 AM3/16/15
to thucydid...@googlegroups.com
I've figured out why I got the above exception, after hours of debugging I caught the root cause of exception(cucumber.runtime.CucumberException: Expected step: "I want to purchase <amount> widgets" got step: "I want to purchase 6 widgets");

Serenity Core is using the latest guava dependency version 18.0, but my project has been the oldest one 13.0. 

So, a little breakdown, there is a method in "SerenityReporter" class =>  private synchronized void generateReports() {getReportService().generateReportsFor(getAllTestOutcomes());}  

If we go into the getReportService, then into getDefaultReporters(), then into FormatConfiguration(EnvironmentVariables environmentVariables), we'll see the Splitter class => Splitter.on(",").trimResults(), this Splitter is not available in 13.0, but in higher versions of guava, and in the debugging I got the MethodNotFoundException, although the IDE console was not generous to cry out this exception. After I upgraded to the version guava 18.0 all tests executed properly without the exception mentioned above.

So, what is the lesson learned? To pay rigorous attention to the POM dependency management of my project.

That's it.

Andy


  

Reply all
Reply to author
Forward
0 new messages