如何用黄瓜激活弹簧靴配置文件 [英] How to activate spring boot profile with cucumber

查看:36
本文介绍了如何用黄瓜激活弹簧靴配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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:

  • Run cucumber tests with mvn: $ mvn test
  • Run cucumber tests in IDE
  • Run cucumber tests on build server
  • No need to use the -Dspring.profiles.active=... argument

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 {
}

这篇关于如何用黄瓜激活弹簧靴配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆