如何有条件地跳过黄瓜中的方案? [英] How do I conditionally skip a scenario in Cucumber?

查看:112
本文介绍了如何有条件地跳过黄瓜中的方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何有条件地跳过方案?

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.

这篇关于如何有条件地跳过黄瓜中的方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆