Match Any Provided Value

Use anyOf matcher to match an expected value against any of the provided values. matchers/universal-compare Universal Compare rule is applicable. Groovy def dateAsText = "2018-06-10" dateAsText.should == anyOf("2018-06-11", LocalDate.of(2018, 6, 10)) Check matchers/import-and-dependencies Import And Dependencies for prerequisites. Java String dateAsText = "2018-06-10"; actual(dateAsText).shouldBe(anyOf("2018-06-11", LocalDate.of(2018, 6, 10))); Check matchers/import-and-dependencies Import And Dependencies for prerequisites.

Mixing Values And Matchers

You can mix values and other matchers passed to anyOf Groovy def dateAsText = "2018-06-10" dateAsText.should == anyOf("2018-06-11", greaterThan(LocalDate.of(2018, 1, 1))) def message = "hello world" message.shouldNot == anyOf("hello", contain("super")) Java String dateAsText = "2018-06-10"; actual(dateAsText).shouldBe(anyOf("2018-06-11", greaterThan(LocalDate.of(2018, 1, 1)))); String message = "hello world"; actual(message).shouldNotBe(anyOf("hello", contain("super")));