我终于弄清楚如何从 XML 中获取列表了。然而,“放心”网站并没有详细说明如何对我得到的列表做出断言。我如何断言这部电影由布鲁斯·威利斯担任 Actor ,并以给定的放心格式,何时,然后?我是否在给定()中使用列表?
@Test
public void verifyBruceWillisIsInDieHard() {
String xmlPath = get(
"http://www.omdbapi.com/?t=Die+Hard&y=&plot=short&r=xml")
.andReturn().body().asString();
XmlPath actor = new XmlPath(xmlPath);
actor.setRoot("movie");
List<String> nameOfFirstActor = actor.getList("movie.@actors");
System.out.println(nameOfFirstActor);
最佳答案
也许是这样的?
when().
get("http://www.omdbapi.com/?t=Die+Hard&y=&plot=short&r=xml").
then().
body("movie.@actors", hasItem("bruce willis"));
关于java - Rest Assured 中的 Xml 断言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31481983/