使用具有Cucumber-JVM的Serenity的场景大纲的所有迭代都失败

时间:2016-08-02 19:08:10

标签: java cucumber cucumber-jvm serenity-bdd

我使用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设置的会话变量。没有意义的是每个电路的打印输出(如下所示)显示正确的信息;但是,断言方法中使用的相同确切变量就好像它们不匹配,即使它们应该是正确的。

输出:

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]>

0 个答案:

没有答案