问题描述
我在测试中遇到错误,已经找到终点,但实际响应为空,但我不知道为什么。我要我的数据提供商向我提供我想要的回复。我得到零。我不知道为什么。我的第二次测试的设备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 (将#修改为@)