空手道 在场景大纲中跳过从 CSV 读取的测试用例 [英] Karate Skip test cases read from CSV in a Scenario Outline

查看:18
本文介绍了空手道 在场景大纲中跳过从 CSV 读取的测试用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用空手道编写数据驱动的测试.我的功能有一个场景大纲,我正在使用 CSV 文件来加载示例,例如测试用例.

I'm writing data-driven-tests with Karate. My Feature has a Scenario Outline and I am using a CSV file to load the examples e.g. the test cases.

是否可以跳过 CSV 文件中的某些行?我不想每次都调用所有的测试.

Is it possible to skip some rows in the CSV files? I don't want to call ALL the tests every time.

推荐答案

假设你有三行,你只想运行一个.您可以读取 csv,然后使用 JsonPath 过滤器对其进行过滤.以下代码将只运行测试用例tc02".

Let's say you have three rows and you just want to run one. You can read the csv and then filter it using JsonPath filters. The following code will run only testcase "tc02".

示例代码:

Feature: CSV Filter

    Background:
        * def data = read('testdata.csv')
        * def data = get data[?(@.testcase=='tc02')]

    Scenario Outline: <testcase>,<desc>
        * def look = "<testcase>,<desc>"
        * print look

        Examples:
            | data |

# testdata.csv
# testcase,desc
# tc01,desc01
# tc02,desc02
# tc03,desc03

这篇关于空手道 在场景大纲中跳过从 CSV 读取的测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆