-1

I have a script which checks returned http status codes.

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

How to assert that actualStatusCode is contained in an array of expectedStatuses' values? Something like:

assertThat(actualStatusCode, anyOf(equalTo(pollStatusCode), equalTo(expectedStatuses)))

Is there any way how to assert this type of values?

Honza Sestak
  • 115
  • 1
  • 2
  • 8

1 Answers1

1
assert actualStatusCode in expectedStatuses

or

assert expectedStatuses.contains(actualStatusCode)
doelleri
  • 19,232
  • 5
  • 61
  • 65