Package com.google.common.truth
Class TruthJUnit
- java.lang.Object
-
- com.google.common.truth.TruthJUnit
-
public final class TruthJUnit extends java.lang.Object
Provides a way to use Truth to perform JUnit "assumptions." An assumption is a check that, if false, aborts (skips) the test. This is especially useful in JUnit theories, parameterized tests, or other combinatorial tests where some subset of the combinations are simply not applicable for testing.For example:
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.TruthJUnit.assume; public void @Test testFoosAgainstBars { assume().that(foo).isNotNull(); assume().that(bar).isNotNull(); assertThat(foo.times(bar)).isEqualTo(blah); }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
TruthJUnit.ThrowableAssumptionViolatedException
-
Field Summary
Fields Modifier and Type Field Description private static StandardSubjectBuilder
ASSUME
private static FailureStrategy
THROW_ASSUMPTION_ERROR
-
Constructor Summary
Constructors Modifier Constructor Description private
TruthJUnit()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StandardSubjectBuilder
assume()
Begins a call chain with the fluent Truth API.
-
-
-
Field Detail
-
THROW_ASSUMPTION_ERROR
private static final FailureStrategy THROW_ASSUMPTION_ERROR
-
ASSUME
private static final StandardSubjectBuilder ASSUME
-
-
Method Detail
-
assume
public static final StandardSubjectBuilder assume()
Begins a call chain with the fluent Truth API. If the check made by the chain fails, it will throwAssumptionViolatedException
.
-
-