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

Serenity with Cucumber right lifecycle #1745

Closed
xescuder opened this issue Jul 24, 2019 · 2 comments
Closed

Serenity with Cucumber right lifecycle #1745

xescuder opened this issue Jul 24, 2019 · 2 comments

Comments

@xescuder
Copy link

xescuder commented Jul 24, 2019

Using Serenity with Cucumber, and debugging I've seen this order of execution:

  • First all methods of plain classes with Before annotation are executed
  • Then all methods on Stepdefs with Before annotation are executed
  • If you've defined a fixture service class in META-INF/services/net.thucydides.core.fixtureservices.FixtureService, then his setup method is called
  • Finally, the method "apply" of any class that implements BeforeAWebdriverScenario, is called.

The last two are used to add capabilities to browser and driver. I suggest or think personally that "Before" annotation, as it's used from steps definitions, is something that needs to be executed after driver has already configured, not before.

For example, if we want to do the login for all our scenarios (Before), and a logoff when scenario is finished (After), we need to start with an already configured driver and capabilities.

Thanks in advance.

@wakaleo
Copy link
Member

wakaleo commented Jul 24, 2019

Most of this is handled by the Cucumber lifecycle code, so I’m not sure how much control the Serenity codebase can have on it.

@wakaleo
Copy link
Member

wakaleo commented Aug 14, 2019

We can't modify the order of the Cucumber step execution. However, if you invoke a step that uses WebDriver at any point, the creation methods will be called. E.g.

    @Before
    public void prepareTests() {
        setTheStage(new OnlineCast());
        OnStage.aNewActor().attemptsTo(
                Open.browserOn().the(TodoReactHomePage.class)
        );
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants