samedi 20 juin 2020

Cucumber tests not reading cucumber.properties file

I created a small snippet Spring Boot application using Junit5 and Cucumber. Because I need to use Junit5 I am using cucumber-junit-platform-engine which does not support the annotation CucumberOptions

As quoted in cucumber.io website:

When property parsing functionality is not provided by the runner (i.e. cucumber-junit-platform-engine) Cucumber will in order of precedence parse properties from system properties, environment variables and the cucumber.properties file.

Because of this I added the following a file named cucumber.properties to my directory src/test/resources with the following content:

cucumber.plugin=json:target/cucumber-reports/,pretty

Yet, when I run my tests this file seems to be ignored as no reports are generated while if I pass the same property through cli arguments such as:

mvn test -Dcucumber.plugin=json:target/cucumber-reports/,pretty it generates the expected json reports.

I have also tried putting the file under src/main/resources and under src/main/test/cucumber.demo (where the feature files are located), but none of these attempts worked. Any idea why the file is being ignored?

Here is my Runner class:

@Cucumber
public class CucumberTest {
    
}

and my Step Definition class:

@CucumberContextConfiguration
@SpringBootTest
public class StepDefinition {

    @Autowired
    String bean;

    //Step Definition 
    (...)

}

Aucun commentaire:

Enregistrer un commentaire