Assert booleans

Rate this post

Given the following example:

<code lang="java">
  public void testAssert() {
    boolean b = false;
    assertThat("Assert boolean b against expected result: true",
        b, Matchers.equalTo(true));
  }
</code>

Returns the following output when the assertion fails:

<code lang="console">
  java.lang.AssertionError: Assert boolean b against expected result: true
  Expected: equal to <true>
    but: was <false>
</code>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.