我正在编写一个测试用例,我需要比较两个包含嵌套对象的数组对象。这是示例代码,请检查。
Class TestGeoNames {
private Status status;
public void setStatus(Status lstatus) {
status = lstatus;
}
public Class Status {
private String mesg;
private String value;
public String getMesg() {
return mesg;
}
public void setMesg(String mesg) {
this.mesg = mesg;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
}
这是测试用例代码:
List<TestGeoNames > result = NetworkManager.executeByJSON(request, TestGeoNames .class);
List<TestGeoNames > Cacheresult = CacheManager.getResponseFromCache(request);
assertNotNull(result);
assertNotNull(Cacheresult);
TestGeonamesBean[] tgb = new TestGeonamesBean[0];
TestGeonamesBean[] cacheResultArray = result.toArray(tgb);
TestGeonamesBean[] resultArray = Cacheresult.toArray(tgb);
assertEquals(true, Arrays.equals(resultArray, cacheResultArray));