Karate 空手道API:将变量传递到其他功能文件不起作用

Karate 空手道API:将变量传递到其他功能文件不起作用,karate,Karate,我正在从另一个功能文件调用登录功能文件,我在其中传递url、用户名和密码,但它对我不起作用。我没有在这里使用背景键,我也不想要 @CallAnotherFeature Feature: Call Login Feature Scenario: Calling Login Test * def config = { endPointURL: 'https://qa1.testurl.com/login',username: 'user123', password: 'password12

我正在从另一个功能文件调用登录功能文件,我在其中传递url、用户名和密码,但它对我不起作用。我没有在这里使用背景键,我也不想要

 @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
变量,但您正在尝试打印它

1.2)
=
应正确放置;)

2。登录功能

2.1)我认为您误解了嵌入表达式的概念。只有将其模板化为JSON时,才可以使用它。但是要调用它,只需使用变量名即可

例如

不是


如果您阅读这里的空手道文档->并参考

我会更清楚地告诉您,您能详细说明您遇到的错误或不起作用的原因吗?非常感谢。我在下面提到的示例中指出,如果存在def变量不能与给定关键字一起使用的任何限制,则会出现这种情况。
* def result = call read('Login.feature') config
Given url endPointURL
And form field username = username
And request { username: '#(username)', password: '#(password)'}
Given url '#(endPointURL)'
And form field username = '#(username)'