为什么一次调用宁静步骤,而忽略另一个调用

时间:2018-08-11 12:05:55

标签: groovy cucumber cucumber-jvm serenity-bdd cucumber-serenity

我有这样的功能

@login
Feature: Login the user

  The user wants to login
  Scenario Outline: Not successful login
    Then Attempt to login user with <password> <login> without success

    Examples:
      | password  | login              |
      |           | test2@test.com  |
      | 123r@R123 |                    |
      | 987r@R789 | test2@test.com  |

黄瓜步骤

@Steps
private UserSteps userSteps        //serenity steps

@Given("Attempt to login user with (.*) (.*) without success")
void userCredentials(String password, String login)
{
    this.password = password
    this.login = login

    token = userSteps.loginUser(password, login)
    Assert.assertNull(token)
}

userSteps.loginUser这是宁静的步骤

@Step
String loginUser(String login, String password)
{
    BEARER_PREFIX.concat(LoginService.login(login, password).body().getAccess_token())
}

问题是:

当我运行此功能时,我看到loginUser方法仅在第一次迭代时被调用。第二,未调用loginUser方法(我无法在调试模式下进入此方法),但是token变量将其值更改为“”(空字符串)。我不知道为什么。有人可以帮忙吗?

上: 当我尝试循环调用登录方法时遇到相同的情况

[
                ["", "test2@test.com"],
                ["123r@R123", ""],
                ["987r@R789", "test2@test.com"]
        ].forEach({ array ->
            try
            {
                token = userSteps.loginUser(array[0], array[1])
                Assert.assertNull(token)
            } catch (NullPointerException npe)
            {
                log.debug("Log in isn't successful...")
            }
        })

0 个答案:

没有答案