简体   繁体   中英

JBehave RunningStoriesFailed exception ; org.jbehave.core.embedder.Embedder$RunningStoriesFailed

getting this error while executing the project :-

java.lang.RuntimeException: org.jbehave.core.embedder.Embedder$RunningStoriesFailed: Failures in running stories: 
sample/test.story: org.jbehave.core.embedder.StoryManager$StoryExecutionFailed: sample/test.story
    at net.serenitybdd.jbehave.runners.SerenityReportingRunner.run(SerenityReportingRunner.java:169)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.jbehave.core.embedder.Embedder$RunningStoriesFailed: Failures in running stories: 
sample/test.story: org.jbehave.core.embedder.StoryManager$StoryExecutionFailed: sample/test.story
    at org.jbehave.core.embedder.Embedder$ThrowingRunningStoriesFailed.handleFailures(Embedder.java:553)
    at org.jbehave.core.embedder.Embedder.handleFailures(Embedder.java:238)
    at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:216)
    at net.serenitybdd.jbehave.embedders.ExtendedEmbedder.runStoriesAsPaths(ExtendedEmbedder.java:60)
    at net.serenitybdd.jbehave.runners.SerenityReportingRunner.run(SerenityReportingRunner.java:167)
    ... 5 more

test.story :-
Meta:

Narrative:
As a user
I want to perform an action
So that I can achieve a business goal

Scenario: scenario description

Given a variable <var>

When save the variable <var>

Then display the variable

Examples:
|var|
|test|

package sample;

import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;

import net.thucydides.core.annotations.Steps;

public class SampleScenario {

  @Steps
  private SampleBehaviour sampleBehaviour;

  @Given("a variable <var>")
  public void checkVar(String var){
    sampleBehaviour.checkVariable(var);
  }

  @When("save the variable <var>")
  public void setVar(String var){
    sampleBehaviour.setVariable(var);
  }

  @Then("display the variable")
  public void printVar(){
    sampleBehaviour.printVar();
  }

}


-----------------------------------------------------------------

package sample;

import net.thucydides.core.annotations.Step;
import net.thucydides.core.steps.ScenarioSteps;

public class SampleBehaviour extends ScenarioSteps {

  private String variable;

  @Step public void checkVariable(String var) {
    if (var == null) {
      System.out.println("var is not valid");
    }
  }

  @Step public void setVariable(String var) {
    variable = var;
  }

  @Step public void printVar() {
    System.out.println("var = " + variable);
  }
}


------------------------------------------------------------------


package testsuite;

import java.util.ArrayList;
import java.util.List;
import org.jbehave.core.annotations.BeforeStories;
import com.gdn.qa.util.restassured.HttpHeaderManager;
import com.gdn.qa.util.restassured.UserDefinedVariables;

import net.serenitybdd.jbehave.SerenityStories;

public class AcceptanceTestSuite extends SerenityStories {

  @BeforeStories
  public void initApi(){
    UserDefinedVariables.initDataUserDefinedVariables();
    HttpHeaderManager.addHeader("Content-Type","application/json");
    HttpHeaderManager.addHeader("Charset","UTF-8");
  }


  @Override
  public List<String> storyPaths(){
    List<String> testLink = new ArrayList<>();
    testLink.add("sample/test.story");
    return testLink;
  }
}

I had a similar issue after update my jbehave-core dependency from an old version 3.10 to 4.5.1 without update the jbehave-junit-runner.

Before the update I have two main dependencies:

    <dependency>
        <groupId>org.jbehave</groupId>
        <artifactId>jbehave-core</artifactId>
        <version>3.10</version>
    </dependency>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>jbehave-junit-runner</artifactId>
        <version>1.2.0</version>
    </dependency>

After update only the jbeave-core the tests broken:

    <dependency>
        <groupId>org.jbehave</groupId>
        <artifactId>jbehave-core</artifactId>
        <version>4.5.1</version>
    </dependency>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>jbehave-junit-runner</artifactId>
        <version>1.2.0</version>
    </dependency>

I had to update to a new version of jbehave-junit-runner as follow:

    <dependency>
        <groupId>org.jbehave</groupId>
        <artifactId>jbehave-core</artifactId>
        <version>4.5.1</version>
    </dependency>
    <dependency>
        <groupId>com.github.valfirst</groupId>
        <artifactId>jbehave-junit-runner</artifactId>
        <version>2.3.0</version>
    </dependency>

This fixed the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM