简体   繁体   English

是否可以从JSON文件传递Cucumber功能中的参数值?

[英]Is it possible to pass parameter value in Cucumber feature from JSON file?

We have current framework in Jbehave where we have large number of test data stored in JSON file and using Parameterconverter to pass value to JBehave stories based on specific environment. 我们在Jbehave中拥有当前框架,在该框架中,我们将大量测试数据存储在JSON文件中,并使用Parameterconverter根据特定环境将值传递给JBehave故事。 I am working on switching framework to Cucumber and wondering if I can use same JSON files or not 我正在将框架切换到Cucumber,想知道是否可以使用相同的JSON文件

Cucumber dosen't support data out side the feature file or from external file . 黄瓜不支持功能文件外部或外部文件中的数据。 What you are looking for is supported with qaf by use of json data provider . qaf通过使用json数据提供程序支持您正在寻找的内容。 With QAF your scenario can look like below: 使用QAF,您的情况如下所示:

@dataFile:resources/${env}/data/logintestdata.json
Scenario: example
    Given use is on login page
    When login using '${username}' and '${password}'
    And store into 'status'
    Then verify that '${status}' is '${isvalid}'
    And verify error message '${expected_msg}'

In above example, value of ${env} in data file path can be provided at the time of execution in different ways .This is just as an example. 在上面的示例中,可以在执行时以不同的方式提供数据文件路径中的${env}值。这只是一个示例。 There can be other alternative ways by using different features of qaf depending on need. 通过根据需要使用qaf的不同功能,可以有其他替代方法。

暂无
暂无

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

相关问题 是否可以将 Java-Enum 作为参数从黄瓜特征文件中传递 - Is it possible to pass Java-Enum as argument from cucumber feature file 如何将 Cucumber 功能文件中的场景名称作为 Cucumber 步骤中的参数传递? - How to pass Scenario name from the Cucumber feature file as a parameter in the Cucumber steps? 如何从一个特征文件表中读取数据并传递值以在空手道的 *.json 文件中设置 json 参数? - How to read data from one feature file table and pass the value to set json parameter in a *.json file in karate? 在黄瓜 .feature 文件中传递数组值 - Pass Array value in cucumber .feature file 如何使用java Cucumber将“#”作为特征文件中的有效参数传递 - How to pass "#" as a valid parameter in feature file using java cucumber TestNG和Cucumber:传入单个功能文件名作为参数 - TestNG & Cucumber: Pass in single feature file name as parameter 如何在Cucumber中将原始数据json格式从特征文件传递到stepdefinition文件 - How to pass raw data json format from feature file to stepdefinition file in Cucumber 如何在黄瓜特征文件中传递值(准确地说是href) - how to pass a value (href to be precise) in a cucumber feature file 如何从黄瓜功能文件中传递 cypress 环境变量? - How to pass cypress environment variable from cucumber feature file? 如何在特征中创建数据并将其作为参数传递给 Cucumber 中的下一个特征 - How to create data in a feature and pass it as a parameter to the next feature in Cucumber
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM