[英]Karate Api Testing - How to pass data from one feature file to another
我需要将数据从一个特征文件传递到另一个特征文件。
功能(1):创建一个新用户
背景:
* url 'http://127.0.0.1:8900/'
* header Accept = 'application/json'
Scenario: Create a new user
Given path '/user'
And request {"email" : "test@test.com", "name" : "Brian"}
When method post
And def newUser = $..id
Then status 201
功能(2):从功能 1 调用 newUser
背景:
* url 'http://127.0.0.1:8900/'
* header Accept = 'application/json'
Scenario: Call User
* def newUser = $..id
* print newUser
请阅读文档: https : //github.com/intuit/karate#calling-other-feature-files
* def aVariable = "can be anything"
* def result = call read('one.feature') { some: 'data', useExpression: #(aVariable) }
在one.feature
您可以访问 JSON“参数”
* print some
哪个应该打印值data
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.