karate - 在空手道中调用其他功能文件时如何在读取中传递变量?
问题描述
我有这样的要求-
- feature1 调用特征库文件。
- 在功能库文件中,我正在读取一个 json。
- 我想通过 featurefile1 配置文件读取。
我有这样的脚本。
特征库 -
Background:
* url baseUrl
* def requestBody = read('#(file)')
特点1 -
Background:
* url baseUrl
* def callFeature = call read('FeatureBase.feature') { file: 'json1.json'}
此代码不起作用,并给我文件未找到错误。
解决方案
该'#(foo)'
技巧仅适用于 JSON。请阅读:https ://github.com/intuit/karate#rules-for-embedded-expressions
请将您的代码更改为:
* def requestBody = read(file)
是的,就是这么简单,就像普通的 JavaScript。
推荐阅读
- amazon-web-services - 同一 ecs 服务上的多个任务
- javascript - 未定义不是对象(评估'_this2.state')
- spring-boot - 在 DTO 响应中使用 Flux
- spring-boot - 通过复合主键的属性进行 Spring Data Cassandra 查询
- c# - winforms 应用程序中的相同活动
- angular - 有没有更好的方法让我按顺序执行多个 HTTP 请求?(角度 12)
- sql - pandas pivot_table SQL 等效项
- c - 结构如何分配自己?
- utf-16 - 对于大量 UTF-16 字符串(多语言),什么是合适的压缩算法?
- android - 有没有办法通过 Nearby Share 共享链接并使用 Nearby Connections API 通过第二台设备上的自定义应用程序接收链接?