JUnit5 support for the existing soft-assertions support (Expect.create JUnit4 Rule)
- Dominant language
- Java
- Stars
- 2.8k
- Forks
- 275
- Avg merge
- 7m
- Merged PRs (30d)
- 4
Description
From a purely JUnit5 perspective, am I missing something?
I made this wrapper around the core Expect function:
```
public class ThingyThing {
public static void softly(final SoftAssertions softly) throws Throwable {
Expect expect = Expect.create();
expect.apply(new Statement() {
@Override
public void evaluate() throws Throwable {
softly.apply(expect);
}
}, Description.EMPTY)
.evaluate();
}
public interface SoftAssertions{
void apply(final Expect expect);
}
}
```
Used like:
```
ThingyThing.softly(expector -> {
expector.that(1).isEqualTo(2);
expector.that(-1).isGreaterThan(0);
});
```
Outputs:
```
2 expectations failed:
1. expected: 2
but was : 1
at io..ThingTest.lambda$testRemit$0(ThingTest.java:113)
2. expected to be greater than: 0
but was : -1
at io..ThingTest.lambda$testRemit$0(ThingTest.java:114)
```
P.s. amazing framework BTW - beautiful. Especially for chained custom objects. Amazing. Wish I'd found it sooner.
Contributor guide
Assessment
This issue has not been assessed yet.