根据条件语句执行不同的api

问题描述 投票:0回答:1

有没有办法根据条件执行api?

Scenario:

And path 'path1'
And request {}
When method post
Then status 200

{execute get1 if condition is true and execute get2 when condition is false} 
#get1
And path 'path2'
When method get
Then status 200

#get2
And path 'path3'
When method get
Then status 200

#get3
And path 'path4'
When method get
Then status 200

我尝试过使用三元运算符的条件语句,但我不确定如何在那里执行代码块。

karate
1个回答
0
投票

请不要这样做。原因解释如下:https://stackoverflow.com/a/54126724/143475

如果您坚持,请参阅:https://stackoverflow.com/a/50350442/143475

© www.soinside.com 2019 - 2024. All rights reserved.