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

Add assertAll? #29

Closed
JLLeitschuh opened this issue Jul 10, 2017 · 3 comments
Closed

Add assertAll? #29

JLLeitschuh opened this issue Jul 10, 2017 · 3 comments

Comments

@JLLeitschuh
Copy link

This might be outside of the scope of this assertion library but a kotlin friendly way of declaring multiple assertions in a single test would be nice to add.

I'm opening this issue due to the discussion in the Junit5:

junit-team/junit5#924

Is this outside the scope of this project? If not, this method should probably throw the org.opentest4j.MultipleFailuresError which would require creating a dependency on opentest4j

@npryce
Copy link
Owner

npryce commented Aug 10, 2017

You can do: assertThat(aThing, isFoo and isBar and isBaz)

where isFoo, isBar and isBar are matchers.

@npryce
Copy link
Owner

npryce commented Aug 10, 2017

I can imagine an API like...

assertAll(
    { assertThat(aThing, isFoo) },
    { assertThat(anotherThing, isBar) },
    { assertThat(andAnother, isBaz) }
)

Or maybe some DSL-ish syntactic sugar:

assert { 
    assertThat(aThing, isFoo) 
} and { 
    assertThat(anotherThing, isBar) 
} and { assertThat(andAnother, isBaz) }

But that API would only have a dependency on opentest4j (for MultipleFailuresError) and not directly on HamKrest.

@npryce npryce closed this as completed Aug 10, 2017
@JLLeitschuh
Copy link
Author

This is now part of JUnit 5 and will be available in release 5.1.
junit-team/junit5#1001

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

2 participants