简体   繁体   English

如何在空手道框架中将 CSV 文件中的数据用于 Soap XML 请求

[英]How to use data in CSV file for Soap XML request in Karate framework

I am tried scenario outline with inbuilt table examples within scenario and it worked well.我在场景中尝试了带有内置表格示例的场景大纲,并且效果很好。 But ask from my team is to have more number of examples using external excel sheet.但是我的团队要求使用外部 excel 表有更多的示例。 So instead of Excel and trying to have it as CSV file for Test data.因此,而不是 Excel 并尝试将其作为测试数据的 CSV 文件。 But tried using csv file with the examples available in Github and failed with those examples.但是尝试将 csv 文件与 Github 中可用的示例一起使用,但这些示例失败了。 As am not a programmer not sure on the mistake I made.因为我不是程序员,所以不确定我犯的错误。 Below is the scenario Outline,下面是场景大纲,

     Feature: Feature1

    Background:

    * url ''
    * configure logPrettyRequest = true
    * configure logPrettyResponse = true 

Scenario Outline: 1   
        * def look= read('../utils/look.xml')

        * replace look

            | token        | value     |

            | @@number@@   | < number> |

            | @@country@@  |< country>| 

        Given url 'baseurl'

        And request look

        When method post

        Then status 200

        Examples:

        |read('name.csv')|

But while running this script console logs as :
0 Scenarios
0 Steps
0m0.000s
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.78 s - [INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

CSV file contents:name.csv

number,country

895201301,173

Issue: No scenarios identified as part of this run问题:本次运行中未确定任何场景

Please suggest way to use CSV file for Test data under scenario Outline of Karate.请建议在空手道大纲场景下使用 CSV 文件作为测试数据的方法。

Couple of issues: The extra space in front of the number and country placeholders has to be removed.几个问题:必须删除数字和国家占位符前面的额外空间。 Also, the placeholders should be enclosed in quotes.此外,占位符应括在引号中。

Sample Code:示例代码:

Feature: Feature1

    Background:
        * url ''
        * configure logPrettyRequest = false
        * configure logPrettyResponse = false

    Scenario Outline: <number>,<country>
        * def look = "@@number@@,@@country@@"
        * replace look
            | token       | value       |
            | @@number@@  | '<number>'  |
            | @@country@@ | '<country>' |
        * print look

        Examples:
            | read('name.csv') |

I faced a similar issue, two points, can you try to add single quotes to all data in your csv file if not already done.我遇到了类似的问题,两点,如果还没有完成,您可以尝试为 csv 文件中的所有数据添加单引号吗? Intead of 'replace' can you try to use set method to set the values on the fly.您可以尝试使用 set 方法动态设置值,而不是“替换”。 Please let me know if this helps请让我知道这可不可以帮你

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

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