[英]How to reuse Minitest support code in Cucumber step definitions?
I have a test suite that uses Minitest. 我有一个使用Minitest的测试套件。 As per the Minitest docs, when I had common functionality, I extracted it into a module, then included that module into
ActionDispatch::IntegrationTest
, giving me access in my tests. 根据Minitest文档,当我具有通用功能时,我将其提取到一个模块中,然后将该模块包含到
ActionDispatch::IntegrationTest
,从而可以在我的测试中进行访问。 In this case, the extracted functionality formatted the requests and parsed the responses in my integration tests. 在这种情况下,提取的功能格式化了请求并在我的集成测试中解析了响应。
Now, I'm bringing in Cucumber, but when I add include MyHelperModule
in my steps definition file, it raises NameError: undefined constant
. 现在,我引入了Cucumber,但是当我在步骤定义文件中添加
include MyHelperModule
时,它将引发NameError: undefined constant
。
How can I include this functionality in my Cucumber step definitions without rewriting the module underneath features/
? 如何在我的Cucumber步骤定义中包含此功能而无需重写
features/
下的模块features/
?
The module currently lives at test/support/my_helper_module.rb
. 该模块目前位于
test/support/my_helper_module.rb
。
In features/support/env.rb
, or in another .rb
file in features/support
, do 在
features/support/env.rb
,或在另一个.rb
文件features/support
,做
require_relative '../../test/support/my_helper_module'
MyHelperModule
will then be available in step definitions. MyHelperModule
将在步骤定义中可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.