Ruby + Cucumber:如何在代码中执行黄瓜? [英] Ruby + Cucumber: How to execute cucumber in code?

查看:118
本文介绍了Ruby + Cucumber:如何在代码中执行黄瓜?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Ruby代码中执行Cucumber功能。

I'd like to execute Cucumber features from within Ruby code.

通常,安装 cucumber gem在命令行上执行一个或多个指定的特性。

Typically the cucumber binary installed with the gem is executed on the command line with one or more features specified.

但是,我想定义一个逻辑来创建动态特性执行流程。

However, I'd like to define logic that creates a dynamic feature execution flow. In other words, the program can work out which features should be executed.

是否可以使用Ruby代码中的指定特征文件来实例化Cucumber,而不是使用命令行?

Is it possible to instantiate Cucumber with specified feature files from Ruby code as opposed to the command line?

推荐答案

我发现邮件列表和一些API的阅读方式。

I discovered how from the mailing list and some API reading.

features="path/to/first.feature path/to/second.feature"
runtime = Cucumber::Runtime.new 
runtime.load_programming_language('rb') 
Cucumber::Cli::Main.new([features]).execute!(runtime)


b $ b

如果你想要执行你的gem的 features / 目录中的所有功能,请传递一个空数组到 Main.new

If you want all features within your gem's features/ directory to be executed, pass an empty array to Main.new instead.

这篇关于Ruby + Cucumber:如何在代码中执行黄瓜?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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