-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resurrect MatcherAssume.assumeThat #322
Comments
I'm willing to take this one on if I can get some guidance on which direction to go. I tried to create a |
To get the record straight on JUnit 5: it has |
There seems to be an integration problem here. Yet another alternative is to somehow optionally allow integration with multiple alternative testing frameworks. In a nutshell: I'm just sparring ideas here, but I don't have a solution either that doesn't require marrying Hamcrest to a particular test framework. |
Yeah, certainly hamcrest used to have integration modules like hamcrest-junit, but eventually it was all rolled back into one again. opentest4j seemed to be the only thing to integrate with, but it's still one more dependency so it seems like people would have to be happy with it to proceed anyway. I wonder what other frameworks like assert4j are doing with junit for assumptions. |
While I was investigating this a bit further, I took my own stab at it. For JUnit 5, I basically settled on the same conclusion: we need a dependency on OpenTest4J. For JUnit 4, I concluded that we should not try to fix it, and instead accept JUnit 4's own I briefly investigated if we should stick it maybe in the In any case, while investigating I ended up with a fix and unit tests so created a PR for it. |
One wonders what happened to hamcrest-junit - it seemed to exist specifically to solve the issue of dependencies by decoupling the two projects entirely, and Hamcrest could then have just introduced a hamcrest-junit5 or whatever to deal with JUnit 5. |
I just ran into the issue while trying to use an assumption with junit5 while using SMOG to generate the matchers. If it's needed I'm all for the existence of a hamcrest-junit5 library, but this lack of assumtions in hamcrest is a serious issue. From what I saw, assumptions throw a TestAbortedException instead of an AssertionFailedError. This TestAbortedException is indeed a opentest4j class. Maybe a construction could be made where the Exception class for a failed assumption is configurable (and maybe by default uses TestAbortedException if it finds opentest4j on the classpath). |
hamcrest-junit used to have
MatcherAssume
class with static methodassumeThat
:https://www.javadoc.io/doc/org.hamcrest/hamcrest-junit/latest/org/hamcrest/junit/MatcherAssume.html#assumeThat(T,%20org.hamcrest.Matcher)
This appears to have been accidentally(?) omitted when relocating
org.hamcrest.junit.*
toorg.hamcrest
.JUnit subsequently have deprecated
Assert.assertThat
on the basis that Hamcrest'sMatcherAssert
has it.This now leaves us in a weird situation where we import JUnit's
Assume.assumeThat
while importing Hamcrest'sMatcherAsserts.assertThat
.(People wanting to use JUnit 5 would probably be in an even worse situation, because JUnit 5 doesn't have
assumeThat
in any form, as far as I can tell, and neither does Hamcrest, leading me to wonder what JUnit 5 users have been doing forassumeThat
all this time...)It would make sense to me if
MatcherAssume
were resurrected so that both can be imported from Hamcrest.The text was updated successfully, but these errors were encountered: