Skip to content

A more readable solution of using describeAs? #52

@karfau

Description

@karfau

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions