Skip to content

BeforeAll hooks are executed before dependency injectionΒ #2797

Closed
@BenjaminTanguay

Description

@BenjaminTanguay

πŸ‘“ What did you see?

When a BeforeAll hook is defined, it is called before any dependencies are injected. This negates a big portion of the usefulness of the hook.

βœ… What did you expect to see?

I expected the injection to be called and completed before any execution hook are invoked. It worked this way in Cucumber 7.0.0. Some change since that version broke this behavior.

πŸ“¦ Which tool/library version are you using?

    <junit.version>5.10.0</junit.version>
    <cucumber.version>7.14.0</cucumber.version>
    <junit-platform-suite.version>1.10.0</junit-platform-suite.version>

The behavior was fine before I updated the dependency from:

    <junit.version>5.8.2</junit.version>
    <cucumber.version>7.0.0</cucumber.version>
    <junit-platform-suite.version>1.8.2</junit-platform-suite.version>

EDIT: Using the reproducer code, it seems that the behavior change happened between version 7.1.0 and 7.2.0.

πŸ”¬ How could we reproduce it?

https://github.com/BenjaminTanguay/cucumber-injection-hook-bug

Execute the reproducer.sh. It will run the failing code in both the current version and the older failing version.

The relevant elements are:
resources/cucumber.properties
test/java/com/example/RunCucumber.java
test/java/com/example/hook/Hook.java
test/java/com/example/injection/CucumberInjector.java
test/java/com/example/injection/InjectionModule.java

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions