"Is" in JUnit 4 assertions

Is there any semantic difference between writing

assertThat(object1, is(equalTo(object2)));

      

and records

assertThat(object1, equalTo(object2)));

      

? If not, I would prefer the first version because it reads better. Are there any other considerations here?

+2


a source to share


2 answers


The documentation says it all:
Decorates another Matcher, keeping the behavior, but allowing the tests to be a little more expressive.
eg. assertThat (cheese, equalTo (smelly))
vs assertThat (cheese, eat (equalTo (smelly)))



http://www.junit.org/apidocs/org/hamcrest/core/Is.html
In other words, you are on the right track.

+1


a source


They are, as far as I know, equivalent. The connector " Is

" just goes to the contained match. There seems to be readability there and possibly backward compatibility.



0


a source







All Articles