Groovy—如何匹配(断言)预期值数组中包含的某个值

Groovy—如何匹配(断言)预期值数组中包含的某个值,groovy,assert,matcher,hamcrest,Groovy,Assert,Matcher,Hamcrest,我有一个脚本检查返回的http状态码 import static org.hamcrest.Matchers.anyOf import static org.hamcrest.Matchers.equalTo import static org.hamcrest.MatcherAssert.assertThat int[] expectedStatuses = [201,204] def pollStatusCode = 202 def actualStatusCode = 201 如何断言

我有一个脚本检查返回的http状态码

import static org.hamcrest.Matchers.anyOf
import static org.hamcrest.Matchers.equalTo
import static org.hamcrest.MatcherAssert.assertThat

int[] expectedStatuses = [201,204]
def pollStatusCode = 202
def actualStatusCode = 201
如何断言ActualStatus代码包含在ExpectedStatus值数组中?比如:

assertThat(actualStatusCode, anyOf(equalTo(pollStatusCode), equalTo(expectedStatuses)))
有没有办法断言这种类型的值

assert actualStatusCode in expectedStatuses


谢谢我对那个资产有点盲目,没有考虑其他的选择。
assert expectedStatuses.contains(actualStatusCode)