简体   繁体   English

如何在Cucumber中将原始数据json格式从特征文件传递到stepdefinition文件

[英]How to pass raw data json format from feature file to stepdefinition file in Cucumber

I have input data as json (complex data) format and want to write cucumber to test rest api. 我有输入数据为json(复杂数据)格式,并且想写黄瓜来测试其余的api。 How can I pass input json data from feature file to step definition file. 如何将输入的json数据从特征文件传递到步骤定义文件。 I know how can i pass multiple parameters , but don't know how to pass json data. 我知道如何传递多个参数,但不知道如何传递json数据。 The input json is very complex and don't know whether i can read it from file in classpath. 输入的json非常复杂,不知道我是否可以从classpath中的文件中读取它。

Don't write the json data in the feature file. 不要将json数据写入功能文件中。 Instead give it a name and refer to it by that name in your scenarios. 而是给它一个名称,并在您的方案中使用该名称进行引用。

Then use the name in your step definitions (or helper methods used by step definitions) to get the data. 然后在步骤定义中使用名称(或步骤定义使用的辅助方法)以获取数据。

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

相关问题 如何从功能文件中获取场景名称以获取stepdefinition Java代码 - How to get the the Scenario name from the feature file to be fetch stepdefinition java code 如何将 Cucumber 功能文件中的场景名称作为 Cucumber 步骤中的参数传递? - How to pass Scenario name from the Cucumber feature file as a parameter in the Cucumber steps? 如何从Jenkins读取Cucumber功能文件 - How to read Cucumber feature file from Jenkins 如何在 Cucumber 功能文件中传递具有不同数量参数的多个示例 - How to pass multiple examples with different number of parameters in Cucumber feature file 如何使用java Cucumber将“#”作为特征文件中的有效参数传递 - How to pass "#" as a valid parameter in feature file using java cucumber 从黄瓜功能文件更新 json 有效负载的最佳方法 - Best way to update json payload from cucumber feature file 如何在黄瓜的特征文件中进行迭代 - How to iterate in feature file of cucumber 如何将外部数据源与 Cucumber 功能文件集成 - how to integrate external data source with Cucumber feature file 如何在运行时使用带有 io.cucumber 的最新黄瓜版本从特征文件中读取黄瓜特征名称 - How to read cucumber feature name from feature file during runtime using latest cucumber version with io.cucumber 黄瓜:如何从功能文件运行特定方案 - cucumber: how to run specific scenario from a feature file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM