jjzjj

notExpected

全部标签

java - 滥用 hamcrest hasItems

我有一个整数列表(当前),我想检查这个列表是否包含预期列表中的所有元素,甚至不包含列表notExpected中的一个元素,所以代码如下:Listexpected=newArrayList();expected.add(1);expected.add(2);ListnotExpected=newArrayList();notExpected.add(3);notExpected.add(4);Listcurrent=newArrayList();current.add(1);current.add(2);assertThat(current,not(hasItems(notExpecte