Wanted: Truth8Junit to support Java 8 types with assume()
I found myself wanting to use a java.util.Optional with TruthJunit.assume():
assume().that(javaUtilOptional).isPresent();
Unfortunately this doesn't work, since TruthJunit doesn't support Java 8 types. Hence this feature request: It's be nice to have a Truth8Junit (analogous to Truth8) to fill this gap.
You can do this with:
import static com.google.common.truth.OptionalSubject.optionals;
assume().about(optionals()).that(javaUtilOptional).isPresent();
This is somewhat documented in https://truth.dev/faq#full-chain, but we were just recently discussing that we should mention it in https://truth.dev/faq#missing-import, too.
The longer-term plan is to make support for java.util.Optional part of core Truth (https://github.com/google/truth/issues/746) as part of dropping support for Java 7.
Sorry that it's confusing and verbose in the meantime.
Thanks!
That workaround is certainly better than what I did:
assume().that(javaUtilOptional.isPresent()).isTrue();
Looking forward to #746,
Belatedly closing, given that #746 was resolved in Truth 1.4.2.