空手道API:将变量传递到其他功能文件不起作用 [英] Karate API : Passing variables to other feature file is not working
本文介绍了空手道API:将变量传递到其他功能文件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@CallAnotherFeature
Feature: Call Login Feature
Scenario: Calling Login Test
* def config = { endPointURL: 'https://qa1.testurl.com/login',username: 'user123', password: 'password123' }
* def result= call read('Login.feature') config
* print result.response
* print 'Sign In-'+signIn
* print 'Sign In Reponse-'+signIn.response
Feature: Login Feature
Scenario: Test Login for different users
* print 'Starting Test','#(endPointURL)'
Given url '#(endPointURL)'
* print 'user name','#(username)'
* print 'Password ','#(password)'
#And form field username = '#(username)'
#And form field password = '#(password)'
And request { username: '#(username)', password: '#(password)'}
When method post
Then status 200
* print response
* match response.loginSuccess == true
在Login.Feature中,我也尝试将用户名和密码作为表单数据传递,尽管这些都不起作用。有人能告诉我我犯了什么错误吗?
我使用的是最新的空手道0.9.0版
推荐答案
我看到您的脚本中存在一些问题
1.呼叫登录功能
1.1)我没有看到signIn
变量在此功能的任何位置初始化,也没有从login feature
中看到,但您正在尝试打印它。
1.2)=
应正确放置;)
* def result = call read('Login.feature') config
2.登录功能
2.1)我认为您误解了嵌入式表达式的概念。只有在将其模板化为JSON时才可以使用它。但是要调用它,您可以简单地使用变量名。例如
Given url endPointURL
And form field username = username
And request { username: '#(username)', password: '#(password)'}
不是
Given url '#(endPointURL)'
And form field username = '#(username)'
如果您从这里阅读空手道文档,我会更清楚->karate Doc并参考karate Demos
这篇关于空手道API:将变量传递到其他功能文件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文