空手道-如何仅在一个环境中运行特定方案? [英] Karate - How to run a specific scenario only in one environment?
问题描述
考虑到有100个场景,我想在产品环境中运行99个场景,在舞台环境中运行100个场景.
Consider there are 100 scenarios and I want to run 99 scenarios in prod environment and 100 on stage environment .
有没有办法在空手道中做到这一点?
Is there a way to achieve this in karate ?
我尝试过的事情 1.创建具有1个场景的功能文件,并创建其余99个功能文件 2.将标签添加到1个方案文件中 3.在运行时忽略
Things I tried 1. Create a feature file with 1 scenario and another feature file with remaining 99 2. Add tag to the 1 scenario file 3. Ignore that while running
但是当我在jenkins作业中使用它时,我必须在两个机器上运行一个命令才能运行
But then when I use it in jenkins job I have to run one command to run on both machines so would not work
推荐答案
The best solution for this case is the karate.abort()
API:
因此在特殊"场景#100中-您可以执行以下操作:
So in the "special" scenario #100 - you can do this:
Scenario:
* eval if (karate.env == 'prod') karate.abort()
# normal scenario steps
请注意,空手道0.9.0中有标签选择器的高级选项向前-但请坚持使用上述解决方案:)
Please note that there are advanced options for tag selectors in Karate 0.9.0 onwards - but just stick to the solution above please :)
这篇关于空手道-如何仅在一个环境中运行特定方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!