Question

I'm trying to create and run a simple JUnitStory to run a .story file.

I have this:

class Scenario1 extends JUnitStory {
    @Delegate MySteps steps = new MySteps()

    @Override
    public Configuration configuration() {
        return new MostUsefulConfiguration()
                .useStoryLoader(new LoadFromRelativeFile(new File('src/test/groovy').toURL()))
                .useStoryReporterBuilder(
                new StoryReporterBuilder()
                        .withDefaultFormats()
                        .withFormats(Format.HTML, Format.CONSOLE, Format.TXT)

        );
    }

    @Override
    public List candidateSteps() {
        final candidateSteps = new InstanceStepsFactory(configuration(), this).createCandidateSteps()
        return candidateSteps;
    }
}

With or without the delegate (copying and pasting in all the annotated methods of MySteps), whenever I run JBehave, I get the following output:

somePattern(){
  // PENDING
}

It's like the individual stories don't pick up the steps.

When I create a "Stories" class and pull all the story files in with storyPaths, the individual steps are defined. Using a debugger, I see that candidateSteps is being hit, but it's not pulling in the data it needs to.

What could possibly be going on here?

Was it helpful?

Solution 4

JBehave is old, underdeveloped technology. Don't use it.

OTHER TIPS

You don't need to delegate to the Steps. And also you should not override candidateSteps, but rather stepsFactory. In later versions of JBehave, candidateSteps is deprecated, to make that preference for the factory method more prominent ( http://jbehave.org/reference/stable/javadoc/core/org/jbehave/core/ConfigurableEmbedder.html#candidateSteps() )

See this blog, where I explained how the basic JBehave configuration works in more detail:

http://blog.codecentric.de/en/2012/06/jbehave-configuration-tutorial/

Andreas

Here is your answer buddy: The package of format has Changed.

This is the deprecated import static org.jbehave.core.reporters.StoryReporterBuilder.Format.HTML;

This is the new one :) import static org.jbehave.core.reporters.Format.HTML;

Took a while to find the answer, but was hidden on the jbehave documentation

Hope it helps! Cheers!

You shouldn't need to use the @Delegate - your JUnitStory is not your Steps class. Can you try passing in steps where you have this?

When you pass in a class that has been bytecode manipulated for Steps classes, JBehave may not see the jbehave annotations anymore.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top