我如何选择不运行黄瓜功能
如果我在 Windows 上,我想不运行某些 Cucumber 功能。谷歌和黄瓜文档似乎在这里变得如此吸引人。
谢谢!
I want to not run certain cucumber feature if, say, I'm on windows. Google and the cucumber docs seemed to turn up dry so appealing here.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
支持泰勒的回答,我想提出以下附加信息:
使用 Cucumber Profiles
如果您正在运行系统在多个不同的环境中,您可能想要创建一个配置文件,然后简单地为您定义一个排除该文件的默认配置文件。
执行(在非 Windows 系统上/默认)
执行(在 Windows 系统上):
您可以将默认值设置为当前所在的任何环境,这样您就不必记住哪些功能不执行;允许您只执行
cucumber
。使用 Cucumber Rake 任务
创建一个 rake 任务来检查您的环境并包含您想要的标签:
执行(在任一平台):
这应该根据您的环境自动包含正确的标签。
Supporting Tyler's answer I would like to propose this additional information:
Use Cucumber Profiles
If you are running the system on multiple different environments you may want to create a profile file and then simply define a default profile for you which excludes the file.
Execution (on a non-windows system / default)
Execution (on a windows system):
You could set the default to whichever environment you are currently on to save yourself having to remember which features do not executing; allowing you to just execute
cucumber
.Use Cucumber Rake Task
Create a rake task that checks your environment and includes the tag you want:
Execution (on either platform):
This should automatically include the right tag based on your environment.
解决这个问题的最佳方法可能是使用标签。
例如,如果您向某个功能添加像
@not-windows
这样的标签,那么您可以自定义您的 Cucumber 执行以忽略它。如果您随后使用 cucumber --tags ~@not-windows 运行测试,它将运行所有未使用 @not-windows 标记的 cuke。 ~ 是导致“not”行为的原因,您可以通过执行
cucumber --tags @not-windows
来仅运行这些标签。在 Windows 中使用第一个 Cucumber 行,您可以阻止有问题的功能(或单个场景)运行,但如果您在另一个操作系统上并正常运行 Cucumber,这些功能仍然会运行。参考:https://github.com/cucumber/cucumber/wiki/Tags
The best way to approach this would likely be using tags.
For example, if you add a tag like
@not-windows
to a feature you can then customize your cucumber execution to ignore this.If you then run your tests with
cucumber --tags ~@not-windows
it will run all cukes that are not tagged by @not-windows. The ~ is what causes the "not" behavior, you could run ONLY these tags by doingcucumber --tags @not-windows
. Using the first cucumber line while in Windows, you can block the problematic features (or individual scenarios) from running but if you're on another OS and run cucumber normally, these will still be ran.Reference: https://github.com/cucumber/cucumber/wiki/Tags