简体   繁体   English

使用BDD(Squish)的多个I / O数据测试场景/以BDD格式的数据驱动测试

[英]Testing a scenario with multiple I/O data in BDD (Squish)/Data driven testing in BDD format

Following is the sample project I am working on. 以下是我正在处理的示例项目。

Scenario :Adder application to be tested in BDD. 场景:要在BDD中测试的Adder应用程序。

Given Adder application is running When Two input values are given corresponding to which we get an output. 给定加法器应用程序正在运行当给定两个输入值时,我们将获得对应的输出。 Then Validate the output field. 然后验证输出字段。

I am, able to execute the test with a set of 2 input values. 我能够使用一组2个输入值执行测试。

Is it possible to execute the same scenario with the different set of input values. 是否可以使用不同的输入值集执行相同的方案。

Yes its possible. 是的,它有可能。 The solution is called Scenario Outline Fe 该解决方案称为Scenario Outline Fe

Scenario Outline: Adder application to be tested in BDD.
Given Adder application is running 
When <input_values> are given corresponding to which we get an output. 
Then Validate the <output> field.      

Examples:
| input_values | output  |
| foo          | bar     |
| new foo      | new bar |

For more info check squish documention link 有关更多信息,请检查压缩文档链接

If you want it for every scenario, use the OnScenarioStart hook... 如果您希望在每种情况下都可以使用它,请使用OnScenarioStart挂钩...

You can also do this without a Scenario Outline, using table data: 您也可以使用表数据在没有方案大纲的情况下执行此操作:

Scenario: Adder application to be tested in BDD.
Given Adder application is running 
Then for each input value provided, verify the output value.
    | inputvalue | outputvalue |
    | foo | bar |
    | new foo | new bar |

You access the table in your step using the context.table object 您可以使用context.table对象在步骤中访问表

Then("for each input value provided, verify the output value", function(context) {
    var table = context.table;

    // Skip initial row with column headers by starting at index 1
    for (var i = 1; i < table.length; ++i) {
        var inputValue = table[i][0];
        var outputValue = table[i][1];
        // make magic happen
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM