gpt4 book ai didi

java - Rest Assured 中的 Xml 断言

转载 作者:行者123 更新时间:2023-12-02 04:30:57 24 4
gpt4 key购买 nike

我终于弄清楚如何从 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com