如何有条件地跳过 Cucumber 中的场景?

编程入门 行业动态 更新时间:2024-10-26 07:31:53
本文介绍了如何有条件地跳过 Cucumber 中的场景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我如何有条件地跳过一个场景?

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 中的场景?

本文发布于:2023-11-25 03:55:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628217.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有条件   跳过   场景   Cucumber

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!