javaselenium-webdriverjbehavejbehave-maven-plugin

Unable to run stories in Jbehave in Eclipse. Need step by step setting up the use fo Jbehave in Eclipse and required details of Jars


Following Steps:

  1. Created new Maven Java Project
  2. Downloaded JBehave JAR file version 3.6.8 and added it to Configure build path > Add External jars and also added the JUnit4
  3. Installed Eclipse Plugin from Help > Install new Softwares
  4. Created a package called SampleTests under the test source folder in my workspace
  5. Created a JBehave story in the above-mentioned package (Login.story)
  6. Created a Java class in the above-mentioned package (LoginTest.java)
  7. Created a Java class in the above-mentioned package (LoginTestSteps.java)
  8. Imported the Given, Named, Then, When annotations in my Java class
  9. Written two different scenarios in my JBehave story file

Stories are successfully mapped to the steps and also added maven and selenium dependencies to Pom file, since I have converted the project in test NG wanted to Run it using Test NG. Is it required to Run as Junit. And also added the library for TestNG in Build path.

I just wanted to know what did I miss in the setting up jbehave in my Maven project and how could I run my stories.

Please suggest

Thanks in Advance!


Solution

  • I don't know you found solution for it or not and don't know TestNg but if you want to run it using JUnit make sure you have the following things:

    Your java story class should extend org.jbehave.core.junit.JUnitStory.
    Unless configured properly JBehave looks for story file in classpath with a name of the story class. If your story class is "LoginTest" it will look for "login_test.story". In the story class put this method:

    @Override
        public InjectableStepsFactory stepsFactory() {        
            // varargs, can have more that one steps classes
            return new InstanceStepsFactory(configuration(), new LoginTestSteps());
        }
    

    Then run it as JUnit test from Eclipse.