SoftwareTestPilot
All discussions
Hana SilvaJul 9

Cucumber hooks: what is the execution order of Before, BeforeStep, After, AfterStep?

Multiple hooks in different classes are firing in a weird order.

cucumberhooks
Related learningExplore Academy skill paths

1 answer

Accepted solution

Hana SilvaJul 10

Order per scenario: Before (all) -> BeforeStep -> Step -> AfterStep -> (repeat per step) -> After (all, reverse of Before). Tagged hooks run only for matching scenarios. Use @Order or the hook order= param to make execution deterministic across classes.