Class ThrowableAssert

All Implemented Interfaces:
Assert<ThrowableAssert,Throwable>, Descriptable<ThrowableAssert>, ExtensionPoints<ThrowableAssert,Throwable>

public class ThrowableAssert extends AbstractAssert<ThrowableAssert,Throwable>
Assertion methods for Throwables.

To create a new instance of this class, invoke Assertions.assertThat(Throwable).

Author:
David DIDIER, Alex Ruiz, Joel Costigliola
  • Constructor Details

    • ThrowableAssert

      protected ThrowableAssert(Throwable actual)
  • Method Details

    • hasMessage

      public ThrowableAssert hasMessage(String message)
      Verifies that the message of the actual Throwable is equal to the given one.
      Parameters:
      message - the expected message.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Throwable is null.
      AssertionError - if the message of the actual Throwable is not equal to the given one.
    • hasNoCause

      public ThrowableAssert hasNoCause()
      Verifies that the actual Throwable does not have a cause.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Throwable is null.
      AssertionError - if the actual Throwable has a cause.
    • hasMessageStartingWith

      public ThrowableAssert hasMessageStartingWith(String description)
      Verifies that the message of the actual Throwable starts with the given description.
      Parameters:
      description - the description expected to start the actual Throwable's message.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Throwable is null.
      AssertionError - if the message of the actual Throwable does not start with the given description.
    • hasMessageContaining

      public ThrowableAssert hasMessageContaining(String description)
      Verifies that the message of the actual Throwable contains with the given description.
      Parameters:
      description - the description expected to be contained in the actual Throwable's message.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Throwable is null.
      AssertionError - if the message of the actual Throwable does not contain the given description.
    • hasMessageEndingWith

      public ThrowableAssert hasMessageEndingWith(String description)
      Verifies that the message of the actual Throwable ends with the given description.
      Parameters:
      description - the description expected to end the actual Throwable's message.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Throwable is null.
      AssertionError - if the message of the actual Throwable does not end with the given description.