问题描述
我们正在使用标签来对功能和特征进行分组.例如,我们有类似的东西:
We are using tags to be able to group features and senarios. For example, we have something like:
@jira=123
Scenario: test scenario 1
...
@jira=456
Scenario: test scenario 2, known failure
...
Scenario: test scenario 3, new feature
现在,我们希望运行未标有@ jira = 123或@ jira = 456的测试.因为我们有许多用@ jira = somevalue标记的功能和场景,所以将它们全部添加都是不切实际的.因此,我正在寻找一种方法来排除使用@jira标记的任何内容.我尝试了〜@ jira和"〜@ jira ="但没有运气.看下面的junit案例:
Now, we are hoping to run test that are not tagged with @jira=123 or @jira=456. Because we have many features and scenarios tagged with the @jira=somevalue, it is impractical to add them all. So I am looking for a way to be able to exclude anything tagged with @jira. I tried ~@jira and "~@jira=" but no luck.Looking at the following junit case:
正在使用"@ foo ="作为标签,但找不到示例.是否有一种方法可以排除由@jira标记的一组场景,而不管标记值如何?
Which is using "@foo=" as a tag, but was not able to find an example. Is there a way to exclude a group of scenarios tagged by @jira, regardless of the tag value ?
推荐答案
是的,我们没有对此进行很好的记录,但是这里的问题可以作为一个开始.空手道实际上支持标签的迷你表达语言.
Yes, we haven't documented this well but this question here can be a start. Karate actually supports a mini expression language for tags.
看看此测试的一些选项: TagsTest.java
Have a look at this test for some options: TagsTest.java
这应该可以满足您的要求,请在注释中进行确认!是的,只需使用下面通常放在 @jira
等处的字符串即可.
And this should work for your requirement, do confirm in the comments ! Yes just use the string below where you would normally put @jira
etc.
!valuesFor('@ jira').isPresent
是的,您可以在命令行上使用以上内容!
YES YOU CAN USE THE ABOVE ON THE COMMAND LINE !!!
这篇关于使用标签排除功能组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!