简体   繁体   English

在黄瓜方案中我可以强制执行什么结果

[英]What results can I force in a cucumber scenario

Using ruby / cucumber, I know you can explicitly call a fail("message") , but what are your other options? 使用红宝石/黄瓜,我知道您可以显式调用fail("message") ,但是您还有其他选择吗?

The reason I ask is that we have 0... I repeat, absolutly NO control over our test data. 我问的原因是我们有0 ...我重复一遍,绝对不能控制我们的测试数据。 We have cucumber tests that test edge cases that we may or may not have users for in our database. 我们有黄瓜测试来测试数据库中可能有或没有用户的边际案例。 We (for obvious reasons) do not want to throw away the tests, because they are valuable; 我们(出于明显的原因)不想放弃测试,因为它们很有价值。 however since our data set cannot test that edge case, it fails because the sql statement returns an empty data set. 但是,由于我们的数据集无法测试该边缘情况,因此失败,因为sql语句返回了空数据集。 Right now, we just have those tests failing, however I would like to see something along the lines of "no_data" or something like that if the sql statement returns an empty data set. 现在,我们只是使那些测试失败,但是我希望看到类似“ no_data”的内容,或者如果sql语句返回一个空数据集,则类似的内容。 So the output would look like 所以输出看起来像

Scenarios:  100 total (80 passed, 5 no_data, 15 fail)

I am willing to use the already implemented "skipped" if there is a skip("message") function. 如果有skip("message")函数,我愿意使用已经实现的“已跳过”。

What are my options so we can see that with the current data, we just don't have any test data for those tests? 我有什么选择,以便我们可以看到当前数据,而这些测试没有任何测试数据? making these manual tests is also not an option. 也不进行这些手动测试。 They need to be run ever week with our automation, but somehow separate from the failures. 它们需要使用我们的自动化系统每周运行一次,但无论如何都会与故障分开。 Failure means defect, no_data found means it's not a testable condition. 失败意味着有缺陷,找到的no_data意味着这不是可测试的条件。 It's the difference between a warning: we have not tested this edge case, and Alert: broken code. 警告:我们尚未测试过这种极端情况,而Alert:代码已损坏,这是两者之间的区别。

You can't invoke 'skipped', but you can certainly call pending with or without an error message. 您无法调用“已跳过”,但可以肯定会在有或没有错误消息的情况下调用pending I've used this in a similar situation to yours. 我在与您类似的情况下使用了此功能。 Unless you're running in strict mode then having pending scenarios won't cause any failures. 除非您以严格模式运行,否则挂起的方案不会导致任何故障。 The problem I encountered was that occasionally a step would get mis-spelled causing cucumber to mark that as pending, since it was not matching a step definition. 我遇到的问题是,有时某个步骤的拼写错误,导致黄瓜将其标记为待处理,因为它与步骤定义不匹配。 That then became lost in the sea of 'legitimate' pending scenarios and was weeks before we discovered it. 然后在“合法的”未决方案的海洋中迷失了,距离我们发现它还差几周。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM