更新时间:2022-12-10 09:27:23
如果可能的话,我会将两个项目中的公共功能提取到一个gem中,然后进行测试。
If possible I'd extract the common functionality out of the two projects into a gem and test it once there.
由于某些原因,两个项目真的必须单独实现相同的功能:
If for some reason the two projects really have to separately implement the same functionality:
您可以通过将一个gem中的步骤定义放在一个文件中,并指示用户 require
该文件在他们的env.rb。
You can provide step definitions in a gem simply by putting them in a file and instructing the user to require
that file in their env.rb.
我不知道一种方法提供功能在gem,可以简单地运行到位,因此您必须提供一个生成器将功能复制到features目录。如果你要生成的功能,它可能更简单的用户生成步骤定义太。
I don't know of a way to provide features in a gem that can simply be run in place, so you'll have to provide a generator that copies the features to the features directory. And if you're going to generate the features it's probably simpler for the user to generate the step definitions too.