Java Assert True assertTrue(String message, boolean condition)

Here you can find the source of assertTrue(String message, boolean condition)

Description

Asserts that a condition is true.

License

Apache License

Parameter

Parameter Description
message the identifying message for the AssertionError ( <code>null</code> okay)
condition condition to be checked

Declaration

public static void assertTrue(String message, boolean condition) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from  w  w w  .  j a  va2s  .  c o m*/
     * Asserts that a condition is true. If it isn't it throws an
     * {@link AssertionError} with the given message.
     * 
     * @param message
     *            the identifying message for the {@link AssertionError} (
     *            <code>null</code> okay)
     * @param condition
     *            condition to be checked
     */
    public static void assertTrue(String message, boolean condition) {
        if (!condition)
            fail(message);
    }

    /**
     * Fails a test with the given message.
     * 
     * @param message
     *            the identifying message for the {@link AssertionError} (
     *            <code>null</code> okay)
     * @see AssertionError
     */
    public static void fail(String message) {
        throw new IllegalStateException(message == null ? "" : message);
    }
}

Related

  1. assertTrue(boolean value)
  2. assertTrue(final boolean condition, final String message)
  3. assertTrue(final boolean result, final String faultDescription)
  4. assertTrue(final String message, final boolean condition)
  5. assertTrue(String message, boolean condition)
  6. assertTrue(String message, boolean condition)
  7. assertTrue(String msg, boolean value)