Skip to content
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

A more readable solution of using describeAs? #52

Open
karfau opened this issue Mar 16, 2012 · 0 comments
Open

A more readable solution of using describeAs? #52

karfau opened this issue Mar 16, 2012 · 0 comments

Comments

@karfau
Copy link

karfau commented Mar 16, 2012

Instead of writing:

assertThat(false, describedAs("false is false", isTrue()));

it would be more "intuitive" to be able to write:

assertThat(false, isTrue().describedAs("a failing false"));

I think describeAs is such a special-case-matcher that it would be OK to extend the matcher-API with this fluent method.

Another Idea would be to have a "fluent wrapper" for such cases which would be extendable. I just can't come up with a cool name for it ("more","multi","extend",...?):

assertThat(false, extend(isTrue()).describedAs("a failing false"));
assertThat(objUnderTest, extend(notNull()).and(hasOwnProperty("id"))));

Or maybe a combination of both worlds:

assertThat(false, isTrue().decorate().describedAs("a failing false"));
assertThat(objUnderTest, notNull().decorate().and(hasOwnProperty("id"))));

What do you think about it?

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

No branches or pull requests

1 participant