Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java hasItems断言错误,iterable包含_Java_Assertion_Hamcrest_Serenity Bdd - Fatal编程技术网

Java hasItems断言错误,iterable包含

Java hasItems断言错误,iterable包含,java,assertion,hamcrest,serenity-bdd,Java,Assertion,Hamcrest,Serenity Bdd,我试图断言一个列表返回我需要的值,但是断言失败了,我不知道为什么差值相等 theActorInTheSpotlight().should(seeThat(Elmenu.menu(SegurosVolutariosUi.CAMPOS_FORMULARIO_SEGUROS_VOLUTARIOS), contains(etiquetasFormulario))) java.lang.AssertionError: 应为:iterable包含[] 但是:第0项:是“Aseguradora” 我认为失败

我试图断言一个列表返回我需要的值,但是断言失败了,我不知道为什么差值相等

theActorInTheSpotlight().should(seeThat(Elmenu.menu(SegurosVolutariosUi.CAMPOS_FORMULARIO_SEGUROS_VOLUTARIOS), contains(etiquetasFormulario)))
java.lang.AssertionError:
应为:iterable包含[]
但是:第0项:是“Aseguradora”

我认为失败的原因是您的方法试图比较整个集合,这并不等于。 如果要检查单个/多个项目是否存在,可以使用hasItem匹配器

// direct check for a single value
theActorInTheSpotlight().should(seeThat(Elmenu.menu(SegurosVolutariosUi.CAMPOS_FORMULARIO_SEGUROS_VOLUTARIOS), hasItem("Aseguradora")))
// or just make an array with items from the list
theActorInTheSpotlight().should(seeThat(Elmenu.menu(SegurosVolutariosUi.CAMPOS_FORMULARIO_SEGUROS_VOLUTARIOS), hasItems(etiquetasFormulario.toArray(new String[0]))))
etiquetasFormulario是一个列表,menu方法返回一个列表
// direct check for a single value
theActorInTheSpotlight().should(seeThat(Elmenu.menu(SegurosVolutariosUi.CAMPOS_FORMULARIO_SEGUROS_VOLUTARIOS), hasItem("Aseguradora")))
// or just make an array with items from the list
theActorInTheSpotlight().should(seeThat(Elmenu.menu(SegurosVolutariosUi.CAMPOS_FORMULARIO_SEGUROS_VOLUTARIOS), hasItems(etiquetasFormulario.toArray(new String[0]))))