空手道-在运行测试用例时编辑xml [英] Karate - editing xml while running the test case

查看:59
本文介绍了空手道-在运行测试用例时编辑xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下xml:

<?xml version="1.0" encoding="utf-8"?>
<request>
    <head>
        <session-id>none</session-id>
    </head>
    <service name="test">
        <function name="testFunc">
            <guids>
                <guid>#guid#</guid>
                <guid>#guid#</guid>
            </guids>
        </function>
    </service>
</request>

我有2个测试用例:

  1. 我想用一个GUID进行测试.
  2. 我想用2个Guid进行测试.

我为两个测试用例创建了2个单独的xml,并且都可以正常工作. 这里的问题是如何使用通用的xml? 我也尝试过使用remove,但是如何从xml中删除单个guid?

I created 2 separate xml for both the test cases and it worked. The question here is how can i use a common xml? Also i tried using remove but how do i remove single guid from the xml?

推荐答案

在空手道.阅读文档: https://github.com/intuit/karate#embedded-expressions

There is something called "embedded expressions" in Karate. Read the docs: https://github.com/intuit/karate#embedded-expressions

示例:

* def guids = <guids><guid>one</guid><guid>two</guid></guids>
* def body = <root>#(guids)</root>

也请参考此文件,它还有许多其他示例和XML数据驱动测试的想法:

Also refer this file, it has a lot of other examples and ideas for XML data-driven tests: xml.feature.

这篇关于空手道-在运行测试用例时编辑xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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