I am looking for a nice way to active a spring profile for my cucumber tests. The cucumber tests need to use a stubbed version of a service which is marked with:
@Profile("test")
@Component
class FooServiceStub extends FooService {...}
The regular service looks like this:
@Profile("prod")
@Component
class FooService {...}
My requirements:
Sources I've found but don't solve my issue:
In more recent cucumber version (6.11.0
) you need a class with spring configuration and you have to annotate that one, not the steps definition
@ActiveProfiles("test")
@CucumberContextConfiguration
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class CucumberSpringConfiguration {
}