0

我已经使用 Cucumber-JVM 和 Serenity 设置了一个场景大纲。当我运行一项测试时,其中一项迭代失败;但是,该场景大纲的其他后续迭代也失败了,即使它们应该通过。

我的场景大纲的简化示例:

Scenario Outline: Validate Circuit Bandwidths

Given I am logged in to the page
When I select '<bandwidth>' for bandwidth
And I click validate
Then the circuit 'bandwidths' match the input

Examples: 
  | bandwidth |
  | DS0       |
  | DS1       |
  | DS3       |

验证代码的页面文件示例:

public void validateCircuitBandwidth(int id, String inputBandwidth) {
    WebElementFacade bandwidth = find(By.id("quoteControl_circuit-" + id + "_bandwidthDropDown"));

    String submittedData = "";
    if (inputBandwidth.equals("null"))
        submittedData = Serenity.sessionVariableCalled("bandwidth");
    else
        submittedData = inputBandwidth;

    String expected = submittedData.toUpperCase();
    String actual = bandwidth.getSelectedVisibleTextValue().toUpperCase();
    System.out.println("Circuit " + id + " | Expected: " + expected + " | Actual: " + actual);

    Assert.assertEquals("Circuit " + id + " Bandwidth does not match input",expected,actual);
}

应该发生的是我还在上传一个 xml 文件以供输入。其中一些字段对于带宽是空白的。当它们为空时,应该从上面所示步骤中输入的带宽中进行选择。此处显示的代码正在检查该点是否为空白(最终是电路 1、2、5、6)。如果它为空,则检查通过 Serenity 设置的会话变量。没有意义的是每个电路的打印输出(如下所示)都显示了正确的信息;然而,在 assert 方法中使用的完全相同的变量表现得好像它们不匹配,即使它们应该是正确的。

输出:

Circuit 0 | Expected: DS1 | Actual: DS1
Circuit 1 | Expected: DS0 | Actual: DS1
[main] ERROR net.serenitybdd.core.Serenity -                                                          

TEST FAILED: 
--------------------------------------------------------------------------
[main] ERROR net.serenitybdd.core.Serenity - TEST FAILED AT STEP Validate circuits bandwidth
[main] ERROR net.serenitybdd.core.Serenity - Circuit 1 Bandwidth does not match input expected:<DS[0]> but was:<DS[1]>
Circuit 0 | Expected: DS1 | Actual: DS1
Circuit 1 | Expected: DS1 | Actual: DS1
Circuit 2 | Expected: DS1 | Actual: DS1
Circuit 3 | Expected: OC3 | Actual: OC3
Circuit 4 | Expected: DS3 | Actual: DS3
Circuit 5 | Expected: DS1 | Actual: DS1
Circuit 6 | Expected: DS1 | Actual: DS1
Circuit 7 | Expected: OC12 | Actual: OC12
[main] ERROR net.serenitybdd.core.Serenity - 

TEST FAILED: 
--------------------------------------------------------------------------
[main] ERROR net.serenitybdd.core.Serenity - TEST FAILED AT STEP Validate circuits bandwidth
[main] ERROR net.serenitybdd.core.Serenity - Circuit 1 Bandwidth does not match input expected:<DS[0]> but was:<DS[1]>
Circuit 0 | Expected: DS1 | Actual: DS1
Circuit 1 | Expected: DS3 | Actual: DS3
Circuit 2 | Expected: DS3 | Actual: DS3
Circuit 3 | Expected: OC3 | Actual: OC3
Circuit 4 | Expected: DS3 | Actual: DS3
Circuit 5 | Expected: DS3 | Actual: DS3
Circuit 6 | Expected: DS3 | Actual: DS3
Circuit 7 | Expected: OC12 | Actual: OC12
[main] ERROR net.serenitybdd.core.Serenity -                                                         

TEST FAILED: 
--------------------------------------------------------------------------
[main] ERROR net.serenitybdd.core.Serenity - TEST FAILED AT STEP Validate circuits bandwidth
[main] ERROR net.serenitybdd.core.Serenity - Circuit 1 Bandwidth does not match input expected:<DS[0]> but was:<DS[1]>
4

0 回答 0