Class TruthJUnit


  • @GwtIncompatible("JUnit4")
    public class TruthJUnit
    extends Object
    Truth - a proposition framework for tests, supporting JUnit style assertion and assumption semantics in a fluent style. TruthJUnit contains a junit-specific "failure strategy" known as an assumption. An assumption is a proposition that, if the proposition is false, aborts (skips) the test. This is especially useful in JUnit theories or parameterized tests, or other combinatorial tests where some subset of the combinations are simply not applicable for testing. TruthJUnit is the entry point for assumptions, via the assume() method. eg:
    
     import com.google.common.truth.Truth.assert_;
     import com.google.common.truth.Truth.assume;
    
     public void @Test testFoosAgainstBars {
       assume().that(foo).isNotNull();
       assume().that(bar).isNotNull();
       assert_().that(foo.times(bar)).isEqualTo(blah);
     }
     
    Author:
    David Saff, Christian Gruber (cgruber@israfil.net)
    • Field Detail

      • THROW_ASSUMPTION_ERROR

        @GwtIncompatible("JUnit4")
        public static final FailureStrategy THROW_ASSUMPTION_ERROR
      • ASSUME

        @GwtIncompatible("JUnit4")
        public static final TestVerb ASSUME
    • Method Detail

      • assume

        @GwtIncompatible("JUnit4")
        public static final TestVerb assume()