Skip to content

Use of BeforeAll/AfterAll in Kotlin-based Cucumber suite does not work as expectedΒ #2934

@ejbartelds

Description

@ejbartelds

πŸ‘“ What did you see?

@BeforeAll in a Kotlin-based Cucumber suite did not work as expected, even though placed in a companion object and annotated @JvmStatic

βœ… What did you expect to see?

I expected the @JvmStatic and @BeforeAll annotated method to be picked up by Cucumber without problems, as a before-all initializer method.

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

cucumber-java 7.20.1 kotlin 2.0.x

πŸ”¬ How could we reproduce it?

See screenhots: in Kotlin, write a suite or a test and have a beforeAll method. See the error appear.
Debug this and set a breakpoint in io.cucumber.java.MethodScanner::scan ; you'll see the beforeAll method is "seen" twice, once as a static final method (whish is OK) and once as a non-final method (in the companion object), which triggers the error.

image
image

πŸ“š Any additional context?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions