I'm doing some TDD using JUnit4, Mockito, and Hamcrest. My current test looks like this:
FeatureFilter featureFilter = FeatureFilter
.describeFeature()
.addFeatureRef("myNewFeature",
thatIsAvailable()
.atEndpoint("/resourceWithFeature"))
.andDisable();
assertThat(featureFilter.isDisabledFor("/resourceWithFeature", null, "myNewFeature"), is(true));
assertThat(featureFilter.isDisabledFor("/irrelevant", null, "myNewFeature"), is(false));
assertThat(featureFilter.isDisabledFor("/resourceWithFeature", null, "self"), is(false));
The second argument to featureFilter.isDisabledFor
should be a username (String
), and what I want the test to communicate is that the username is irrelevant in this case. If I were in the context of a test double I could use a Matcher
such as any(String.class)
, but that's not an option here.
How would you, as a developer, communicate this assertion's intent?
There is a feature called JUnit Theories. @Test
and Theory
have a different focus on testing:
Applied to your problem: