Grouping assertions dynamically
- Dominant language
- Java
- Stars
- 2.8k
- Forks
- 275
- Avg merge
- 7m
- Merged PRs (30d)
- 4
Description
The Expect TestVerb is great for short JUnit tests but I write non-JUnit system tests that run for hours. I would like to use Truth for all the assertion checks I make throughout my tests but I want a way to be able to group some checks together so I get as much information at the point of failure while still stopping the test at the point of failure.
Sort of the design I'm thinking is this
```java
TestVerb testVerb = ...;
try (GroupVerb groupVerb = GroupVerb.from(testVerb)) {
FooSubject subject = groupVerb.about(foos()).that(foo);
subject.hasProperty1();
subject.hasProperty2();
subject.hasProperty3();
}
```
Checks made with a GroupVerb are gathered like with `Expect` and when GroupVerb is "closed," the group failures are packaged like Expect and sent to the failure strategy of the wrapped test verb. I could use this to check multiple properties on the same subject or even iterate a list of subjects, checking them all.
I have a working prototype for GroupVerb but it requires being in the `com.google.common.truth` package because `getFailureStrategy()` on `AbstractVerb` is protected. I thought this might be a good feature for the library though.
Contributor guide
Assessment
This issue has not been assessed yet.