Class Truth


  • public final class Truth
    extends Object
    The primary entry point for Truth, a library for fluent test assertions.

    Compare these example JUnit assertions...

    
     assertEquals(b, a);
     assertTrue(c);
     assertTrue(d.contains(a));
     assertTrue(d.contains(a) && d.contains(b));
     assertTrue(d.contains(a) || d.contains(b) || d.contains(c));
     
    ...to their Truth equivalents...
    
     assertThat(a).isEqualTo(b);
     assertThat(c).isTrue();
     assertThat(d).contains(a);
     assertThat(d).containsAtLeast(a, b);
     assertThat(d).containsAnyOf(a, b, c);
     

    Advantages of Truth:

    For more information about the methods in this class, see this FAQ entry.

    For people extending Truth

    The most common way to extend Truth is to write a custom Subject. (The other, much less common way is to write a custom FailureStrategy.) For more information, visit those types' docs.

    Author:
    David Saff, Christian Gruber (cgruber@israfil.net)