Class MessageFormatter


  • public class MessageFormatter
    extends java.lang.Object
    Formats the messages to be included in assertion errors.
    • Constructor Detail

      • MessageFormatter

        MessageFormatter()
    • Method Detail

      • format

        public java.lang.String format​(Description d,
                                       Representation p,
                                       java.lang.String format,
                                       java.lang.Object... args)
        Interprets a printf-style format String for failed assertion messages. It is similar to String.format(String, Object...), except for:
        1. the value of the given Description is used as the first argument referenced in the format string
        2. each of the arguments in the given array is converted to a String by invoking Representation.toStringOf(Object).
        Parameters:
        d - the description of the failed assertion, may be null.
        format - the format string.
        args - arguments referenced by the format specifiers in the format string.
        Returns:
        A formatted String.
        Throws:
        java.lang.NullPointerException - if the format string is null.
      • format

        private java.lang.Object[] format​(Representation p,
                                          java.lang.Object[] args)
      • asText

        private java.lang.String asText​(Representation p,
                                        java.lang.Object o)