空手道 Api 测试 - 如何将数据从一个特征文件传递到另一个特征文件 [英] Karate Api Testing - How to pass data from one feature file to another

查看:29
本文介绍了空手道 Api 测试 - 如何将数据从一个特征文件传递到另一个特征文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将数据从一个特征文件传递到另一个特征文件.

I need to pass data from one feature file to another.

功能(1):创建一个新用户

Feature(1): Create a new user

背景:

* 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

Feature(2): Call newUser from feature 1

背景:

* 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参数"

And in one.feature you can get access to the JSON "argument"

* print some

哪个应该打印值 data

这篇关于空手道 Api 测试 - 如何将数据从一个特征文件传递到另一个特征文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆