如何使用Cucumber-jvm将一个功能运行到一个Junit测试中 [英] How to run more then one feature into one junit test with cucumber-jvm

查看:137
本文介绍了如何使用Cucumber-jvm将一个功能运行到一个Junit测试中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个具有不同标签(@ tag_1和@ tag_2)的功能文件.另外,我有junit测试类:

I have 2 feature files with different tags(@tag_1 and @tag_2). Also, I have junit test class:

@RunWith(Cucumber.class)
@CucumberOptions(features = path/to/features, tags = {"@tag_1", "@tag_2"})

但是,如果我运行junit test,则在控制台中会看到以下内容:

But if I run junit test, in console I see this:

0个场景
0个步骤
[path/to/features]中的所有要素均未与过滤器匹配:[@ tag_1,@ tag_2]

0 scenarios
0 steps
None of the features at [path/to/features] matched the filters: [@tag_1, @tag_2]

但是在功能中,我会在功能词之前看到这些标签

But in features I see these tags before Feature word

怎么了?

推荐答案

如果您看一下黄瓜标签

If you have a look to cucumber tags specifications:

  • 以逗号分隔的标记经过ORed操作
  • 在单独的标记中传递的标记进行AND运算
  • Tags which are comma separated are ORed
  • Tags which are passed in separate —tags are ANDed

翻译成黄瓜-jvm:

  • 如果要执行 OR (运行带有@ tag1或@ tag2注释的功能)

  • If you want to do an OR (run features annotated with @tag1 or @tag2)

@CucumberOptions(功能=路径/功能/特征,标签= {"@ tag_1,@ tag_2"})

@CucumberOptions(features = path/to/features, tags = {"@tag_1, @tag_2"})

如果要进行 AND (运行同时带有@ tag1和@ tag2注释的功能)

If you want to do an AND (run features annotated with both @tag1 and @tag2)

@CucumberOptions(功能=路径/目标/功能,标签= {"@ tag_1","@ tag_2"})

@CucumberOptions(features = path/to/features, tags = {"@tag_1", "@tag_2"})

希望有帮助.

这篇关于如何使用Cucumber-jvm将一个功能运行到一个Junit测试中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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