如何使用 Wiremock 更改 GET 方法中的状态
How change state in GET method with wiremock
一时间有点不明白。如何更改我的 GET 方法中的状态?我明白,这需要使用场景,但我的代码不起作用。始终状态 = 状态一。 (我正在使用 json)
我有一个方法GET,我想在再次检查他之后改变它的状态。
例如(三个 json 文件 - 三个状态 - 一个 GET 方法):
第一个场景
{
"scenarioName": "check status event",
"requiredScenarioState": "Started",
"request": {
"method": "GET",
"urlPathPattern": "/cashboxes/[0-9]+/registration/[0-9]+"
},
"response": {
"status": 200,
"jsonBody": {
"status": "status one",
},
"headers": {
"Content-Type": "application/json"
}
}
}
第二种情况
"scenarioName": "check status event",
"requiredScenarioState": "Started",
"newScenarioState": "status two",
"request": {
"method": "GET",
"urlPathPattern": "/cashboxes/[0-9]+/registration/[0-9]+"
},
"response": {
"status": 200,
"jsonBody": {
"status": "status two",
},
"headers": {
"Content-Type": "application/json"
}
}
}
第三种情况
"scenarioName": "check status event",
"requiredScenarioState": "status two",
"newScenarioState": "status three",
"request": {
"method": "GET",
"urlPathPattern": "/cashboxes/[0-9]+/registration/[0-9]+"
},
"response": {
"status": 200,
"jsonBody": {
"status": "status three",
},
"headers": {
"Content-Type": "application/json"
}
}
}
或者我可以在 once 方法中使用一些延迟来更改状态吗?
你也需要在第一个存根上有一个 newScenarioState
元素,否则你永远无法脱离 Started
状态。
newScenarioState
是当存根匹配时场景将转换到的状态。
一时间有点不明白。如何更改我的 GET 方法中的状态?我明白,这需要使用场景,但我的代码不起作用。始终状态 = 状态一。 (我正在使用 json)
我有一个方法GET,我想在再次检查他之后改变它的状态。 例如(三个 json 文件 - 三个状态 - 一个 GET 方法):
第一个场景
{
"scenarioName": "check status event",
"requiredScenarioState": "Started",
"request": {
"method": "GET",
"urlPathPattern": "/cashboxes/[0-9]+/registration/[0-9]+"
},
"response": {
"status": 200,
"jsonBody": {
"status": "status one",
},
"headers": {
"Content-Type": "application/json"
}
}
}
第二种情况
"scenarioName": "check status event",
"requiredScenarioState": "Started",
"newScenarioState": "status two",
"request": {
"method": "GET",
"urlPathPattern": "/cashboxes/[0-9]+/registration/[0-9]+"
},
"response": {
"status": 200,
"jsonBody": {
"status": "status two",
},
"headers": {
"Content-Type": "application/json"
}
}
}
第三种情况
"scenarioName": "check status event",
"requiredScenarioState": "status two",
"newScenarioState": "status three",
"request": {
"method": "GET",
"urlPathPattern": "/cashboxes/[0-9]+/registration/[0-9]+"
},
"response": {
"status": 200,
"jsonBody": {
"status": "status three",
},
"headers": {
"Content-Type": "application/json"
}
}
}
或者我可以在 once 方法中使用一些延迟来更改状态吗?
你也需要在第一个存根上有一个 newScenarioState
元素,否则你永远无法脱离 Started
状态。
newScenarioState
是当存根匹配时场景将转换到的状态。