Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assert alternative (or)

I have an endpoint which returns either true or false. Is it somehow possible to tell Hamcrest with RestAssured to check whether there exist one of mentioned two ? I've already tried containsString, hasItems etc, but none of them works i.e it checks for both of them.

get("http://localhost:8080/trueOrFalse")
        .then()
        .body(hasItems("true", "false")); // TRUE or FALSE not both 
like image 234
ashur Avatar asked Feb 10 '26 09:02

ashur


1 Answers

There is an either() method on the CombinableMatcher class.

Example

assertThat(result, either(is(true)).or(is(false)));
like image 123
Alex Avatar answered Feb 13 '26 02:02

Alex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!