Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Before/After Scenario not working in Serenity BDD #117

Closed
jaspreetmanchinda opened this issue Mar 17, 2017 · 4 comments
Closed

Before/After Scenario not working in Serenity BDD #117

jaspreetmanchinda opened this issue Mar 17, 2017 · 4 comments

Comments

@jaspreetmanchinda
Copy link

I have already posted a question in other forum too.
http://stackoverflow.com/questions/42860315/before-after-scenario-not-working-in-jbehave-serenity-bdd

When I run the test the code does not enter the before and after scenario block.
The version i am using is
<serenity.version>1.2.3-rc.5</serenity.
<serenity.jbehave.version>1.21.0</serenity.jbehave.version>

@wakaleo
Copy link
Member

wakaleo commented Mar 17, 2017

@BeforeScenario and @AfterScenario are JBehave annotations and are handled by JBehave - Serenity doesn't do anything special to run them, as they should be run by JBehave. Is there something special that you need to do with JBehave to use them? Can you create a sample JBehave project where they work correctly?

@jaspreetmanchinda
Copy link
Author

Thanks for the quick response.
I will try with a sample jbehave project and share the update

@jaspreetmanchinda
Copy link
Author

I created two sample project of below archetype
1.) serenity-jbehave-archetype version 1.2.0
2.)jbehave-simple-archetype version 4.1

and tried before and after scenario in both the sample projects its working fine
one thing that I noticed is when I run the default feature file with before and after it executes, but when I execute it with my feature file it doesn't.
I am testing the rest service, Have three layers: one Step file GWT, one step file @steps which has the implementation and one common util which have the get, post implementation and other common implementation.

What can be the case where before and after wont execute?

@wakaleo
Copy link
Member

wakaleo commented Mar 27, 2017

The JBehave API seems to have changed, it seems you now need to add the ScenarioType parameter:

    @BeforeScenario(uponType = ScenarioType.ANY)
    public void setTheStage() {
        OnStage.setTheStage(new OnlineCast());
    }

@wakaleo wakaleo closed this as completed Mar 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants