cucumber / cucumber-jvm

Cucumber for the JVM
https://cucumber.io
MIT License
2.7k stars 2.02k forks source link

cucumber.glue propertie from cucumber.properties always overwritten by default value. #2622

Closed reverant closed 2 years ago

reverant commented 2 years ago

👓 What did you see?

When setting cucumber.glue property in cucumber.properties it is always overwritten by a package of class with cucumber options annotation.

✅ What did you expect to see?

If glue is set in cucumber.properties don't overwrite it by default value.

📦 Which tool/library version are you using?

Cucumber 7.4.1 used with java 11.0.13

🔬 How could we reproduce it?

Steps to reproduce the behaviour:

  1. set glue in cucumber.properties.
  2. run test
mpkorstanje commented 2 years ago

I'm assuming you're using JUnit 4 with cucumber-junit?

Unfortunately using the package of the runner class as the default glue path, ignoring anything else, has been a feature for a long time now. This is something that can not be changed without impacting a large amount of users.

Consider upgrading to JUnit 5 with the cucumber-junit-platform-engine. It does not have this behaviour.

https://github.com/cucumber/cucumber-jvm/tree/main/cucumber-junit-platform-engine

reverant commented 2 years ago

Ah sorry, I forgot to mention I'm using cucumber-testng version.

mpkorstanje commented 2 years ago

Ah, I see.

Then it is mostly the same problem. But if you are running your tests via the XML suite you can define the glue there and it will override the annotation.

https://github.com/cucumber/cucumber-jvm/tree/main/cucumber-testng#configure-cucumber-options-via-testng-xml

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Example Suite">
    <parameter name="cucumber.glue" value="com.example.glue"/>

    <test name="Vegetable garden" preserve-order="true">
        <parameter name="cucumber.features" value="classpath:com/example/features/vegetable"/>

        <classes>
            <class name="com.example.RunCucumberTests"/>
        </classes>
    </test>

    <test name="Herb garden" preserve-order="true">
        <parameter name="cucumber.features" value="classpath:com/example/features/herbs"/><classes>
            <class name="com.example.RunCucumberTests"/>
        </classes>
    </test>
</suite>