类 AssertionErrors


  • public abstract class AssertionErrors
    extends Object
    JUnit independent assertion class.
    从以下版本开始:
    3.2
    作者:
    Lukas Krecan, Arjen Poutsma
    • 方法详细资料

      • fail

        public static void fail​(String message)
        Fails a test with the given message.
        参数:
        message - describes the reason for the failure
      • fail

        public static void fail​(String message,
                                Object expected,
                                Object actual)
        Fails a test with the given message passing along expected and actual values to be added to the message.

        For example given:

         assertEquals("Response header [" + name + "]", actual, expected);
         

        The resulting message is:

         Response header [Accept] expected:<application/json> but was:<text/plain>
         
        参数:
        message - describes the value that failed the match
        expected - expected value
        actual - actual value
      • assertTrue

        public static void assertTrue​(String message,
                                      boolean condition)
        Assert the given condition is true and raise an AssertionError if it is not.
        参数:
        message - the message
        condition - the condition to test for
      • assertEquals

        public static void assertEquals​(String message,
                                        Object expected,
                                        Object actual)
        Assert two objects are equal raise an AssertionError if not.

        For example:

         assertEquals("Response header [" + name + "]", actual, expected);
         
        参数:
        message - describes the value being checked
        expected - the expected value
        actual - the actual value