What is the alternative to using the Deprecated Hamcrest method is()?

Brad picture Brad · Sep 26, 2012 · Viewed 33.7k times · Source

I use the following code at the moment to assert on a boolean value, however the method org.hamcrest.Matchers.is() is deprecated.

assertThat(someValue, is(false));

Is there a simple alternative syntax to test for boolean values without resorting to assertTrue() which gives you poor failure messages like "java.lang.AssertionError"


Edit after receiving comments/answers

My initial concerns were raised because Eclipse shows the following import statement as deprecated

enter image description here

On viewing the Hamcrest API docs there are 3 overloaded variations of the is() method, only one of which is deprecated.

Therefore, to clarify the comment from @mark and the answer from @matt, the use of is() that I have posted above is valid and not deprecated.

Answer

matt b picture matt b · Sep 26, 2012

Have you tried equalTo(T)?

assertThat(someValue, equalTo(false));

I don't see that is(T) is deprecated - is(Class) is deprecated however.