cucumber "OR"条款?

标签 cucumber automated-tests calabash

是否可以在 Cucumber 中指定某种“OR”(替代)子句?

即如果我对某个事件有两个有效响应,如果其中任何一个发生,我希望我的测试能够通过。

类似的事情:

"When I press a button"
"Then I should see the text 'Boo'"
"Or I should see the text 'Foo'"

我的特定场景是登录屏幕。当我尝试使用一些随 secret 码登录时,如果服务器正在工作,我应该看到一条错误消息“密码无效”,如果服务器不工作,我应该看到一条消息“网络错误”。

最佳答案

您无法真正使用 Gherkin 定义 OR 功能,但您可以传入一个列表并检查列表中的值之一是否与返回的值匹配。

定义列表:

Then the greeting service response will contain one of the following messages
      |Hello how are you doing?|
      |Welcome to the front door!|
      |How has your day been?|
      |Come right on in!|

检查 list :

    @Then("the get messages service response will contain one of the following messages")
    public void text_matching_one_of_the_following(List<String> greetingMessages){
        boolean success = false;
        for(String message : greetingMessages){
            assertTrue(textMatchesResponse(message));
        }
    } 

关于 cucumber "OR"条款?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25422279/

相关文章:

android - 使用 Android 版 Calabash,如何编写滚动到并触摸特定 ListView 行的步骤?

android - Calabash-android:附加到正在运行的应用程序

java - 在新目录中执行功能文件时出错

ruby-on-rails - ElasticSearch和 cucumber

java - 如何在 Selenium 中正确实现 PageFactory 注释?

ruby - 使用 Ruby、Cucumber 和 Aruba 检查测试主目录中的文件

gradle - Allure 报告的 jvmArgs 设置

ruby - Watir webdriver 鼠标悬停(悬停)- Firefox Chrome IE 之间的区别

ios - 多个并发iOS模拟器

javascript - react 测试库 id 而不是 data-testid?