-1

I am creating a frame work for automation testing using jbehave story files and junit for running it.

PFB:

this is  my story file which is located in src/test/java/com/cdm/story/

This is my class file from where I am running the code:

class which extends the junitstories

I have defined the path of the story file even then junit is not able to collect the story for execution. getting this response:

org.jbehave.core.io.StoryResourceNotFound: Story path 'ConnectedDevicesManagementPage.story' not found by class loader sun.misc.Launcher$AppClassLoader@2f0e140b
    at org.jbehave.core.io.LoadFromClasspath.resourceAsStream(LoadFromClasspath.java:44)
    at org.jbehave.core.io.LoadFromClasspath.loadResourceAsText(LoadFromClasspath.java:29)
    at org.jbehave.core.io.LoadFromClasspath.loadStoryAsText(LoadFromClasspath.java:38)
    at org.jbehave.core.embedder.PerformableTree.storyOfPath(PerformableTree.java:193)
    at org.jbehave.core.embedder.PerformableTree.addStories(PerformableTree.java:68)
    at org.jbehave.core.embedder.StoryManager.runStories(StoryManager.java:78)
    at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:203)
    at com.cdm.BrowserFactory.BrowserSelector.storyPaths(BrowserSelector.java:142)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.getStoryPathsFromJUnitStories(JUnitReportingRunner.java:142)
    at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.<init>(JUnitReportingRunner.java:45)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

If I am changing the storypath as below then getting this in console:

Sep 23, 2016 5:43:33 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
1474632816231   Marionette  INFO    Listening on port 53647
Sep 23, 2016 5:43:38 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Processing system properties {}
Using controls EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=false,ignoreFailureInView=false,verboseFailures=false,verboseFiltering=false,storyTimeoutInSecs=300,threads=1]

(BeforeStories)


(AfterStories)

Generating reports view to 'C:\Users\CMD_AUTOMATION\CDM_AUTOMATIOM\target\jbehave' using formats '[stats, console, txt, junitscenarioreporter]' and view properties '{reports=ftl/jbehave-reports-with-totals.ftl, decorateNonHtml=true}'
Reports view generated with 0 stories (of which 0 pending) containing 0 scenarios (of which 0 pending)

I have stuck with this from two days, trying lot of things from google but unable to solve it yet..please help me to resolve this.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
faiz
  • 1
  • 1

1 Answers1

0

First, update your jbehave core from 4.0 to 4.0.5 since junit runner is using reflection to do the work.

then, in your storyPaths method no need to call embedder.runStoriesAsPaths, it will be called from the run method.

just add this in storyPaths method:

@Override
public List<String> storyPaths() {
    List<String> stories = new StoryFinder().findPaths(
            codeLocationFromClass(this.getClass()), "**/*.story", "**/excluded*.story");
    return stories;
}