空手道条件后台执行

Karate conditional background execution

我如何设置空手道,以便在 运行 本地 运行 和预生产 运行 宁的子集时 运行 一堆测试?

当我 运行 在本地进行测试时,我会启动一个模拟服务器并使用 Background 进行设置。在预生产中,不需要模拟服务器,所以我想跳过 Background 执行。

此外,我无法使用 @Before 注释来启动我的 Cucumber Test Runner。

使用标签。参考文档:https://github.com/intuit/karate#cucumber-tags

@preprod
Scenario: some scenario

我个人更喜欢从 JUnit 测试中启动模拟服务器的方法 类,并且有很多示例,例如:example

但您也可以这样做,请参阅 conditional logic 上的文档:

* eval if (karate.env == 'preprod') karate.call('mock-start.feature')

I was not able to use the @Before annotation

这不是很有帮助,请按照此处的说明进行操作:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue