我如何有条件地跳过一个场景?
How do I conditionally skip a scenario?
例如,我希望仅在满足某些条件时继续一个场景,但如果它不存在,我不希望它注册为失败.
For example, I wish to continue a scenario only if certain conditions are met, but I do not want it to register as a failure if it's not present.
推荐答案这是我遇到的一个问题.我编写的测试是针对具有不断变化的 BE 数据库的 UI,我目前无法在其中包含静态数据.这意味着有时可能没有测试数据.不是通过也不是失败,只是无法运行.
This is an issue I had. The tests I write are against a UI that has a constantly changing BE database that I am currently unable to have static data in. This means that some times it is possible that there is no data for the test. Not a pass not a fail, just unable to run.
我发现最好的方法是调用一个待处理的黄瓜.
The way that I found to work best was to invoke a cucumber pending.
示例测试:
Scenario: Test the application Given my application has data When I test something Then I get a result示例步骤定义:
Given /^my application has data$/ do pending unless application.has_data? end这些是我可以看到的结果:
These are the kind of results I can see:
201 scenarios (15 pending, 186 passed) 1151 steps (15 pending, 1136 passed)值得注意的是,我进行了额外的调试并标记了这些测试,以便我可以随时再次运行这些待处理的测试.
It's worth noting that I have extra debugging and have these tests tagged so that at any time I can run these pending tests again.
希望这会有所帮助,本.
Hope this helps, Ben.
更多推荐
如何有条件地跳过 Cucumber 中的场景?
发布评论