0
我正在編寫測試用例在RestAssured中使用spring mvc測試其他webservices。RestAssured測試仇恨
休息響應
{
"links": [
{
"rel": "self",
"href": "http://www.localhost.com:8080/v1/communities?offset=0&limit=10"
},
{
"rel": "next",
"href": "http://www.localhost.com:8080/v1/communities?offset=10&limit=10"
}
],
"content": [
{
.....
和我的測試用例是
when().
get("/communities").
then().
root("links").
body("href", new ResponseAwareMatcher() {
public Matcher<? extends Object> matcher(ResponseBody response) {
return equalTo(new String[] {"http://www.localhost.com:8080/v1/communities?offset=0&limit=10", "http://www.localhost.com:8080/v1/communities?offset=10&limit=10"});
}
});
測試案例失敗,錯誤
java.lang.AssertionError: 1 expectation failed.
JSON path links.href doesn't match.
Expected: ["http://www.localhost.com:8080/v1/communities?offset=0&limit=10", "http://www.localhost.com:8080/v1/communities?offset=10&limit=10"]
Actual: [http://www.localhost.com:8080/v1/communities?offset=0&limit=10, http://www.localhost.com:8080/v1/communities?offset=10&limit=10]
我甚至嘗試
equalTo("[http://www.localhost.com:8080/v1/communities?offset=0&limit=10, http://www.localhost.com:8080/v1/communities?offset=10&limit=10");
這會出錯誤的
java.lang.AssertionError: 1 expectation failed.
JSON path links.href doesn't match.
Expected: [http://www.localhost.com:8080/v1/communities?offset=0&limit=10, http://www.localhost.com:8080/v1/communities?offset=10&limit=10]]
Actual: [http://www.localhost.com:8080/v1/communities?offset=0&limit=10, http://www.localhost.com:8080/v1/communities?offset=10&limit=10]
我用的放心3.0.1。感謝您的幫助提前。