如何将一个特征文件中 table 的值传递给另一个特征文件的 JSON 请求?
How to pass value from table in one feature file to another feature file's JSON request?
在功能文件 1 中:
Feature: validate the table
Scenario: Table parameterization
And table kit
| homeMobileCountryCode | homeMobileNetworkCode | radioType | carrier | considerIp | cellTowers | wifiAccessPoints |
| 310 | 410 | 'GSM' | 'Vodafone' | 'true' | | |
| 200 | 500 | 'GSM' | 'Vodafone' | 'true' | | |
| 100 | 350 | 'GSM' | 'Vodafone' | 'true' | | |
And def result = call read( ' classpath:2.2_parameter_pass.feature ') kit
And print result
在功能文件 2 中
功能:可重复使用的功能来创建单个猫
Scenario:
And print "caled func"
Given url 'https://www.googleapis.com/geolocation/v1/geolocate'
And param key = AIzaSyB2jt4BQ9McqBXAe8dYcp1CwKf0oGFlWuc
And request { homeMobileCountryCode : ' #(homeMobileCountryCode) ', homeMobileNetworkCode : ' #(homeMobileNetworkCode) ', radioType : ' #(radioType) ', carrier : ' #(carrier) ', considerIp : ' #(considerIp) ', cellTowers : ' #(cellTowers) ', wifiAccessPoints : ' #(wifiAccessPoints)'}
When method post
Then status 200
但 JSON 请求中的值未成功传递。
请帮忙解决这个问题。
很难弄清楚,因为您没有提供完整的工作示例,也没有说明您面临的错误。
让我印象深刻的一件事是这一行肯定会失败,你应该在字符串周围使用引号
And param key = 'AIzaSyB2jt4BQ9McqBXAe8dYcp1CwKf0oGFlWuc'
您在请求中还有 un-necessary 个空格,例如' #(radioType) '
会引起麻烦,做这个'#(radioType)'
请多加小心
在功能文件 1 中:
Feature: validate the table
Scenario: Table parameterization
And table kit
| homeMobileCountryCode | homeMobileNetworkCode | radioType | carrier | considerIp | cellTowers | wifiAccessPoints |
| 310 | 410 | 'GSM' | 'Vodafone' | 'true' | | |
| 200 | 500 | 'GSM' | 'Vodafone' | 'true' | | |
| 100 | 350 | 'GSM' | 'Vodafone' | 'true' | | |
And def result = call read( ' classpath:2.2_parameter_pass.feature ') kit
And print result
在功能文件 2 中 功能:可重复使用的功能来创建单个猫
Scenario:
And print "caled func"
Given url 'https://www.googleapis.com/geolocation/v1/geolocate'
And param key = AIzaSyB2jt4BQ9McqBXAe8dYcp1CwKf0oGFlWuc
And request { homeMobileCountryCode : ' #(homeMobileCountryCode) ', homeMobileNetworkCode : ' #(homeMobileNetworkCode) ', radioType : ' #(radioType) ', carrier : ' #(carrier) ', considerIp : ' #(considerIp) ', cellTowers : ' #(cellTowers) ', wifiAccessPoints : ' #(wifiAccessPoints)'}
When method post
Then status 200
但 JSON 请求中的值未成功传递。
请帮忙解决这个问题。
很难弄清楚,因为您没有提供完整的工作示例,也没有说明您面临的错误。
让我印象深刻的一件事是这一行肯定会失败,你应该在字符串周围使用引号
And param key = 'AIzaSyB2jt4BQ9McqBXAe8dYcp1CwKf0oGFlWuc'
您在请求中还有 un-necessary 个空格,例如' #(radioType) '
会引起麻烦,做这个'#(radioType)'
请多加小心