我如何有条件地跳过方案?
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示例步骤def:
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.
希望这会有所帮助, Ben。
Hope this helps, Ben.
更多推荐
如何有条件地跳过黄瓜中的方案?
发布评论