Karate 单个场景中的空手道多url访问
我想在一个场景中访问多个url 当url在Karate 单个场景中的空手道多url访问,karate,Karate,我想在一个场景中访问多个url 当url在背景中定义且另一个url在场景中使用时,url会发生更改 如果使用路径,则该行为不是预期的。 它能在背景中修复url吗 Feature: examples Background: * url 'https://jsonplaceholder.typicode.com' Scenario: get all users and then get the first user by id Given path 'users' Whe
背景中定义且另一个url在场景中使用时,url会发生更改
如果使用路径
,则该行为不是预期的。
它能在背景中修复url
吗
Feature: examples
Background:
* url 'https://jsonplaceholder.typicode.com'
Scenario: get all users and then get the first user by id
Given path 'users'
When method get
Then status 200
Given url 'https://api.github.com/search/repositories'
And param q = 'intuit/karate'
When method get
Then status 200
# The expected behavior is accessed to 'https://jsonplaceholder.typicode.com/users'.
# But the accual behavior is accessed to 'https://api.github.com/search/repositories/users'.
Given path 'users'
When method get
Then status 200
不,但如果您移动给定url'https://api.github.com/search/repositories“
到第二个场景:
它可以正常工作
这是一个深思熟虑的设计。看这张照片。它进行了两次调用,但是url
只被提及一次,因为第二次调用只是一个路径
添加。这是典型的REST模式
因此,如果您确实需要执行不同的API调用,则必须使用完整的url
:
Background:
* def baseUrl = 'https://jsonplaceholder.typicode.com'
Scenario: get all users and then get the first user by id
Given url baseUrl
And path 'users'
When method get
Then status 200
Given url 'https://api.github.com/search/repositories'
And param q = 'intuit/karate'
When method get
Then status 200
Given url baseUrl
And path 'users'
When method get
Then status 200
谢谢你的回复。好的,我在每个给定的中使用url
关键字。