除了方案大纲以外,还有其他方法可以多次运行黄瓜方案吗?

时间:2019-05-21 12:31:29

标签: java cucumber

场景概述:

  • 鉴于我有一个来自system-env的视频流
  • 当我请求流URL时
  • 然后收到http响应200
  • 我确认“ data1”是正确的
  • 我确认“ data2”是正确的

示例:

  |data1|data2|

  |abc|def|

  |test1|test2 |

确保上述方案针对不同的输入“流”运行的最佳方法是什么(当前从系统属性接收到gradle任务,作为单个流作为标记,并且方案使用相同的标记)?

我想在以后将其扩展到50个流或100个流,我不想在示例中添加所有这些示例,因为它太麻烦了。

我正在考虑从yaml文件(假设为50)中收集所有流,并对每个流运行上述方案。

1 个答案:

答案 0 :(得分:0)

这是您可以使用Jackon库从yaml中读取数据并在脚本中使用它们的高级方法。您可以根据保存流索引的系统变量stream获取流URL。

Given("^I have the stream from system-env$", () ->
{
    String myTargetStream ="";
    String[] streams = get_text_from_yaml_using_jackon_library_here;//you have to implement this
    int stream = System.getProperty("stream");
    if (stream+1>streams.length){
        myTargetStream = streams[0];
        System.setProperty("stream", "0");
    }else{
        myTargetStream = streams[stream+1];
        System.setProperty("stream", Integer.toString(stream+1));
    }
    // now use the myTargetStream in your test or generate the feature file here
});