cucumber-jvm icon indicating copy to clipboard operation
cucumber-jvm copied to clipboard

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

Open ejbartelds opened this issue 1 year ago • 6 comments

👓 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

ejbartelds avatar Oct 23 '24 07:10 ejbartelds