简体   繁体   中英

How to reuse Minitest support code in Cucumber step definitions?

I have a test suite that uses 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. 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 .

How can I include this functionality in my Cucumber step definitions without rewriting the module underneath features/ ?

The module currently lives at test/support/my_helper_module.rb .

In features/support/env.rb , or in another .rb file in features/support , do

require_relative '../../test/support/my_helper_module'

MyHelperModule will then be available in step definitions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM