How do I assert to accept one of multiple possible values in JUnit

I have a test that returns some value after completion. The returned value is a String and can have one of several possible values based on some if condition in the test. But in the assert statement I can check only one of the Expected values not both.

How can I do this? Thank you.

Answers


Using a boolean expression with OR would not work?


I will use AssertJ for this

 assertThat(value).isIn(expected1, expected2, expected3);

The code is much simpler than with Hamcrest.


Need Your Help

Disabling Strict Standards Errors in WordPress 3.7 with PHP 5.4

php wordpress apache httpd.conf osx-mavericks

I am trying to disable STRICT Error reporting in WordPress 3.7 via my php.ini file after updating my computer to OS X 10.9. I am running PHP Version 5.4.17, the one that ships with Mavericks.

Why is one ko.mapping.fromJS working and other one not?

javascript jquery asp.net-mvc asp.net-mvc-3 knockout.js

I have a class a class named Foo and Foo contains Model. I am doing a ko.applyBinding on Foo. The Foo class has a function which retrieves JSON from server and then I do: