Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JBehave - all steps marked pending?

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?

like image 834
Stefan Kendall Avatar asked Jan 11 '12 21:01

Stefan Kendall


2 Answers

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

like image 154
AndreasEK Avatar answered Oct 29 '22 18:10

AndreasEK


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!

like image 36
rodrigoms Avatar answered Oct 29 '22 18:10

rodrigoms