We are using cucumber + selenium to facilitate e2e tests. We are using following dependencies to leverage on spring dependency injection.
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>6.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.6.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.2.6.RELEASE</version>
<scope>provided</scope>
</dependency>
Then we configure spring context using these two classes
@ContextConfiguration(classes = SpringContextConfig.class)
@CucumberContextConfiguration
public class CucumberSpringConfiguration {
}
@PropertySource("application.properties")
@ComponentScan("com.example.e2e")
public class SpringContextConfig {
}
As we can se we properties source is defined explicitly pointing to a given file. Is there a way to achieve the "magic" that Spring Boot does with profiles and properties files?
For example I would expect spring when specifying -Dspring.profiles.active=dev
to merge
application-dev.properties
with application.properties
and giving the final context properties.