JavaHamcrest icon indicating copy to clipboard operation
JavaHamcrest copied to clipboard

Deprecate the Is matcher, for eventual deletion

Open npryce opened this issue 11 years ago • 5 comments

The Is matcher doesn't do anything, and so should be deleted.

Factory methods for is should not be added to the domain-specific factory classes introduced as part of #85

npryce avatar Dec 24 '14 16:12 npryce

@npryce doesn't Is matcher provide a better language like feel to the assert statements? assertThat(object1, is(equalTo(object2)); sounds much natural than assertThat(object1, equalTo(object2));

npathai avatar Dec 26 '14 06:12 npathai

Yes. This issue is for the deprecation. Deletion is another issue.

On Thursday, December 25, 2014, Steve Freeman [email protected] wrote:

Probably should be deprecated first. There are lots of people who seem to like it.

— Reply to this email directly or view it on GitHub https://github.com/hamcrest/JavaHamcrest/issues/88#issuecomment-68096966 .

npryce avatar Dec 26 '14 10:12 npryce

Hamcrest doesn't aim to replicate natural language but implement a compositional notation in which each component of an expression means something. The is matcher goes against that design. It's a historical mistake.

On Friday, December 26, 2014, Narendra Pathai [email protected] wrote:

@npryce https://github.com/npryce doesn't Is matcher provide a better language like feel to the assert statements? assertThat(object1, is(equalTo(object2)); sounds much natural than assertThat(object1, equalTo(object2));

— Reply to this email directly or view it on GitHub https://github.com/hamcrest/JavaHamcrest/issues/88#issuecomment-68126219 .

npryce avatar Dec 26 '14 10:12 npryce

@npryce Aha now I got it. Thanks.

npathai avatar Dec 26 '14 12:12 npathai

I like the is(value) shortcut. It's shorter to type and as npryce pointed out is more natural to read. I do agree that is(matcher) is a bit overkill since it doesn't change the matcher outcome compared to the contained matcher, but I also agree that for readability I like the option to use it. Also, its existence doesn't hurt anything and removing it will therefore only be a hassle for end-users since it would be a breaking change.

CC007 avatar Jan 24 '23 15:01 CC007