我在我的测试中得到了一个错误,我找到了终点,但是我得到了一个空的实际响应,我不知道为什么。我要求我的数据提供者提供我想要的答案。我回来了。我不知道为什么。我的第二个测试设备id不是空的。在这种情况下,这是一个足够的测试吗?
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,
"confirmed": true,
"id": 164002,
"ownGoal": false,
"penalty": false,
"period": "FIRST_HALF",
"playerId": 60817,
"teamId": "2"
},
{
"clockTime": 1312,
"confirmed": true,
"id": 267245,
"ownGoal": false,
"penalty": false,
"period": "FIRST_HALF",
"playerId": 136629,
"teamId": "1"
},
{
"clockTime": 1760,
"confirmed": true,
"id": 758030,
"ownGoal": false,
"penalty": false,
"period": "FIRST_HALF",
"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",
"finished": false,
"gameTimeInSeconds": 900,
"goals": [
{
"clockTime": 640,
"confirmed": true,
"id": 678606,
"ownGoal": false,
"penalty": false,
"period": "FIRST_HALF",
"playerId": 560617,
"teamId": "1"
},
{
"clockTime": 864,
"confirmed": true,
"id": 164002,
"ownGoal": false,
"penalty": false,
"period": "FIRST_HALF",
"playerId": 60817,
"teamId": "2"
}
],
"period": "FIRST_HALF",
"possibles": [],
"corners": [],
"redCards": [],
"yellowCards": [],
"startDateTime": "2018-03-20T10:49:38.655Z",
"started": true,
"teams": [
{
"association": "HOME",
"name": "Manchester-United",
"teamId": "HOME"
},
{
"association": "AWAY",
"name": "Leeds-United",
"teamId": "AWAY"
}
]
}
},
{
"fixtureId": "3",
"fixtureStatus": {
"displayed": false,
"suspended": true
},
"footballFullState": {
"homeTeam": "Garforth FC",
"awayTeam": "York FC",
"finished": false,
"gameTimeInSeconds": 950,
"goals": [
{
"clockTime": 640,
"confirmed": true,
"id": 678606,
"ownGoal": false,
"penalty": false,
"period": "FIRST_HALF",
"playerId": 560617,
"teamId": "1"
}
],
"period": "FIRST_HALF",
"possibles": [],
"corners": [],
"redCards": [],
"yellowCards": [],
"startDateTime": "2018-03-20T10:49:38.655Z",
"started": true,
"teams": [
{
"association": "HOME",
"name": "Garforth-FC",
"teamId": "HOME"
},
{
"association": "AWAY",
"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
暂无答案!
目前还没有任何答案,快来回答吧!