如何解决请放心测试失败java.lang.AssertionError:1个期望失败 XML路径FixtureId不匹配
我在测试中遇到错误,已经找到终点,但实际响应为空,但我不知道为什么。我要我的数据提供商向我提供我想要的回复。我得到零。我不知道为什么。我的第二次测试的设备ID不为null。在这种情况下,这是否足够测试?
Json
[
{
"fixtureId": "1","fixtureStatus": {
"displayed": false,"suspended": true
},"footballFullState": {
"homeTeam": "Dagenham & Redbridge","awayTeam": "Österreich","finished": false,"gameTimeInSeconds": 2656,"goals": [
{
"clockTime": 640,"confirmed": true,"id": 678606,"ownGoal": false,"penalty": false,"period": "FIRST_HALF","playerId": 560617,"teamId": "1"
},{
"clockTime": 864,"id": 164002,"playerId": 60817,"teamId": "2"
},{
"clockTime": 1312,"id": 267245,"playerId": 136629,{
"clockTime": 1760,"id": 758030,"playerId": 131840,"teamId": "2"
}
],"period": "SECOND_HALF","possibles": [],"corners": [],"redCards": [],"yellowCards": [],"startDateTime": "2018-03-20T10:49:38.655Z","started": true,"teams": [
{
"association": "HOME","name": "Dagenham-&-Redbridge","teamId": "HOME"
},{
"association": "AWAY","name": "Österreich","teamId": "AWAY"
}
]
}
},{
"fixtureId": "2","fixtureStatus": {
"displayed": true,"suspended": false
},"footballFullState": {
"homeTeam": "Manchester United","awayTeam": "Leeds United","gameTimeInSeconds": 900,"name": "Manchester-United","name": "Leeds-United",{
"fixtureId": "3","footballFullState": {
"homeTeam": "Garforth FC","awayTeam": "York FC","gameTimeInSeconds": 950,"teamId": "1"
}
],"name": "Garforth-FC","name": "York-FC","teamId": "AWAY"
}
]
}
}
]
端点:
String endpointfixtureId = "http://localhost:3000/fixtures/{fixtureId}";
测试:
public class test extends enablers{
@DataProvider(name = "getData")
public Object[][] getData() {
return new Object[][]{
{"1"},{"2"},{"3"}
};
}
@Test(dataProvider = "getData")
public void GetUserId(String fixtureId) {
given().log().all().and().
pathParam("fixtureId",fixtureId).
when().
get(endpointfixtureId).
then().
assertThat().
body(("fixtureId"),equalTo(fixtureId));
}
@Test
public void GetId() {
given().log().all().
when().
get(endpoint).
then().
assertThat().
statusCode(200).
and().
body("body",hasSize(numberOfId)).
and().
body("fixtureId",notNullValue());
}
}
错误:
java.lang.AssertionError: 1 expectation failed.
XML path fixtureId doesn't match.
Expected: 2
Actual: nullErrorCannot GET /fixtures/2
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。