peterdemaeyer / javahamcrest Goto Github PK
View Code? Open in Web Editor NEWThis project forked from hamcrest/javahamcrest
Java (and original) version of Hamcrest
Home Page: http://hamcrest.org/
License: Other
This project forked from hamcrest/javahamcrest
Java (and original) version of Hamcrest
Home Page: http://hamcrest.org/
License: Other
There are some obsolete modules in the JavaHamcrest project that should be removed: hamcrest-core
, hamcrest-library
, hamcrest-integration
.
"Is" is about object identity, corresponding to the ==
Java operator.
"Is equal to" is about object equality, corresponding to the equalTo
method.
Hamcrest 2.x gets these semantics wrong because it defaults the Is matcher to the semantics of equalTo.
To fix this, is
should default to sameInstance
instead of equalTo
.
This would be a breaking change, not in the compile-time sense of the work, but in the semantical sense.
Something for Hamcrest 3.x.
The design of the Matcher
API is not ideal:
Matcher
interface is a prominent member of the API, and intuitively, users would implement it. But apparently that is not the intent. Code smell: Matcher._dont_implement_Matcher___instead_extend_BaseMatcher_
.BaseMatcher
or a subclass thereof instead. What does it add? A toString
and describeMismatch
implementation, but neither are final so subclasses can override them - which would make them eligible to implement Matcher
directly, but then they're not supposed to do that. It makes no sense - why have a Matcher
interface then in the first place? The impression I get is that someone thought that "an interface looks better on the API than an abstract class".The solution is to consolidate both in one abstract class.
Or, alternatively, an interface with default methods.
Now that Java source compatibility has been updated to 1.8 (on this fork), we are no longer restricted to Gradle 4.x, and we can finally update Gradle (and Checkstyle).
Whenever one implements Matcher
, one has to implement at least two methods: matches(Object)
and describeTo(Description description)
. It would be vastly more intuitive if there was a default implementation for the latter. Then one could implement a Matcher
using a lambda. And usually, it's hard to come up with a good implementation of describeTo
anyway.
IntelliJ warns about the unused generic type parameter <T>
on Matcher<T>
. I think it can be removed without loss of functionality. It will cause less confusion.
Currently, Hamcrest's assertThat
family of methods is defined on MatcherAssert
.
It would be better to rename this to MatcherAssertions
, to align with JUnit 5's Assertions
which defines the assert
family of methods.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.