-
Notifications
You must be signed in to change notification settings - Fork 260
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
Allow logical operations on assertions #991
Comments
The fluent version would be a very big API change to pretty much every Subject. It couldn't work as you propose, because I see no huge technical barriers to implementing |
I likewise don't expect us to add this. One minor reason for that is that the "failure path" for assertions can be pretty slow, like when it constructs very long failure messages. If we wanted to support logical operations "properly," we'd design an API that allowed deferring that work until later.
One additional downside that that will expose is that the only way to fail with full information will be to dump the whole list of failure messages, which may be quite long. The alternative way to do this would be for us to implement "Fuzzy Truth for single objects." I forget whether we have an external feature request open about that yet. But it would address any concerns around performance or failure messaging. |
That assumes that callers perform a single assertion per StringSubject a = holds.that(myString);
a.startsWith("http:");
a.startsWith("https:"); ...when they could just write... holds.that(myString).startsWith("http:");
holds.that(myString).startsWith("https:"); But we could imagine seeing multiple assertions on the same |
I think this is actually what I really wanted :) |
It would be nice if there was some way of performing logical operations on assertions, whether fluently or not.
The text was updated successfully, but these errors were encountered: