Skip to content

Introduce MatcherMatcher, a hamcrest matcher for matchers#1

Merged
scarytom merged 0 commit intohamcrest:masterfrom
scarytom:master
Dec 13, 2012
Merged

Introduce MatcherMatcher, a hamcrest matcher for matchers#1
scarytom merged 0 commit intohamcrest:masterfrom
scarytom:master

Conversation

@scarytom
Copy link
Member

@scarytom scarytom commented Apr 5, 2012

Hi Steve, Tom Denley here.

Now that you have transitioned hamcrest onto github, I thought I'd try to contribute some of our work at youDevise back into hamcrest, starting with the MatcherMatcher. This is a hamcrest matcher for hamcrest matchers, which facilitates test-driven development of new matcher implementations.

The MatcherMatcher allows for three assertions to be made against a matcher implementation:

assertThat(myFooMatcher, is(aMatcherWithDescription(equalTo("a Foo"))));
assertThat(myFooMatcher, is(aMatcherThatMatches(new Foo())));
assertThat(myFooMatcher, is(aMatcherGivingAMismatchDesctiptionOf(new Bar(), equalTo("was a Bar"))));

@sf105
Copy link
Member

sf105 commented Apr 5, 2012

Thanks Tom,

I'll take a look. Is TG happy with any licensing issues?

That said, this might be better in the hamcrest-java-extras I've started.

Actually, do you think they'd be prepared to release some of the other generic matchers, like JSON?

Also, you might want to look at the Condition stuff I've been introducing. I'm hoping it helps with compound matchers.

Ta

S.

On 5 Apr 2012, at 11:19, Tom Denley wrote:

Hi Steve, Tom Denley here.

Now that you have transitioned hamcrest onto github, I thought I'd try to contribute some of our work at youDevise back into hamcrest, starting with the MatcherMatcher. This is a hamcrest matcher for hamcrest matchers, which facilitates test-driven development of new matcher implementations.

The MatcherMatcher allows for three assertions to be made against a matcher implementation:

assertThat(myFooMatcher, is(aMatcherWithDescription(equalTo("a Foo"))));
assertThat(myFooMatcher, is(aMatcherThatMatches(new Foo())));
assertThat(myFooMatcher, is(aMatcherGivingAMismatchDesctiptionOf(new Bar(), equalTo("was a Bar"))));

You can merge this Pull Request by running:

git pull https://github.com/scarytom/JavaHamcrest master

Or you can view, comment on it, or merge it online at:

#1

-- Commit Summary --

  • add /classes to .gitignore to prevent eclipse compiled classes being checked in.
  • introduce the MatcherMatcher to hamcrest. This matcher enables unit testing of new Matcher implementations using hamcrest to do the legwork -- eating our own dog food!

-- File Changes --

M .gitignore (1)
A hamcrest-library/src/main/java/org/hamcrest/matcher/MatcherMatcher.java (109)
A hamcrest-unit-test/src/main/java/org/hamcrest/matcher/MatcherMatcherTest.java (120)

-- Patch Links --

https://github.com/hamcrest/JavaHamcrest/pull/1.patch
https://github.com/hamcrest/JavaHamcrest/pull/1.diff


Reply to this email directly or view it on GitHub:
#1

Steve Freeman

Winner of the Agile Alliance Gordon Pask award 2006
Book: http://www.growing-object-oriented-software.com

+44 797 179 4105
Twitter: @sf105
Higher Order Logic Limited
Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ.
Company registered in England & Wales. Number 7522677

@scarytom
Copy link
Member Author

scarytom commented Apr 5, 2012

I'm sure that TG will be fine with this contribution. We've recently started open sourcing our Matcher extensions here https://github.com/youdevise/Matchers -- and it can only be a win for us if we get things further upstream and into hamcrest itself. Our Matchers project is pretty sparse at the moment, but I would expect us to grow it to include most of our generic matchers (including the JSON ones) as we extract them from our various internal codebases. My hope is to cherry-pick the good bits from our Matchers project and re-package them for inclusion into hamcrest, tidying things up as I go -- and ensuring the tests are up to scratch -- then issuing pull requests for you. Let me know if you want me to adopt a different strategy, or if you need anything formal signed off to cover licensing.

I imagine that anything too niche would better sit in hamcrest-java-extras, but I'd like to get MatcherMatcher a bit further up, so I can use it to tidy up some of the existing unit tests for the other matchers in hamcrest-library. I noticed that they are all JUnit3 at the moment -- would you be happy for me to start modernising them? I'm keen to give back to a project that has been so tremendously useful to me personally over the years.

I'll have a look over the Condition stuff over the Easter weekend if I can, sounds interesting.

Thanks,
Tom

@sf105
Copy link
Member

sf105 commented Apr 5, 2012

I'll take a look at your contributions. I'm not totally sure that matchermatcher belongs in the core, since it might be a bit too recursive ;)

We still support junit 3, so it doesn't really matter if we use it for the tests. That said, maybe it is time to modernise. not sure.

I'm off for a few days, ping you when i get back.

S.

On 5 Apr 2012, at 22:25, Tom Denley wrote:

I'm sure that TG will be fine with this contribution. We've recently started open sourcing our Matcher extensions here https://github.com/youdevise/Matchers -- and it can only be a win for us if we get things further upstream and into hamcrest itself. Our Matchers project is pretty sparse at the moment, but I would expect us to grow it to include most of our generic matchers (including the JSON ones) as we extract them from our various internal codebases. My hope is to cherry-pick the good bits from our Matchers project and re-package them for inclusion into hamcrest, tidying things up as I go -- and ensuring the tests are up to scratch -- then issuing pull requests for you. Let me know if you want me to adopt a different strategy, or if you need anything formal signed off to cover licensing.

I imagine that anything too niche would better sit in hamcrest-java-extras, but I'd like to get MatcherMatcher a bit further up, so I can use it to tidy up some of the existing unit tests for the other matchers in hamcrest-library. I noticed that they are all JUnit3 at the moment -- would you be happy for me to start modernising them? I'm keen to give back to a project that has been so tremendously useful to me personally over the years.

I'll have a look over the Condition stuff over the Easter weekend if I can, sounds interesting.

Thanks,
Tom


Reply to this email directly or view it on GitHub:
#1 (comment)

Steve Freeman

Winner of the Agile Alliance Gordon Pask award 2006
Book: http://www.growing-object-oriented-software.com

+44 797 179 4105
Twitter: @sf105
Higher Order Logic Limited
Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ.
Company registered in England & Wales. Number 7522677

@scarytom
Copy link
Member Author

scarytom commented Apr 5, 2012

Roger that. Have a good break and we'll speak next week. Can always meet for a coffee if you want.

@scarytom scarytom merged commit 72520cb into hamcrest:master Dec 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments