doc / ch.tutteli.atrium.reporting / IAssertionFormatter / format

format

open fun format(assertion: IAssertion, methodObject: AssertionFormatterMethodObject): Unit

Formats the given assertion and appends the result to the sb of the given methodObject.

This method should not be overridden (unfortunately an interface method cannot yet be final in Kotlin). This default implementation checks whether the given assertion is an IAssertionGroup and calls throwNotIntendedForAssertionGroups in case it is; calls formatNonGroup with the given assertion and methodObject otherwise.

This function should be in sync with canFormat. If canFormat returns true then this method should be able to format the given assertion without problems. If canFormat returns false then this method should throw an UnsupportedOperationException. Moreover, it should throw an UnsupportedOperationException in case the assertion is an IAssertionGroup -- use IAssertionFormatter.throwNotIntendedForAssertionGroups for this purpose.

Parameters

assertion - The assertion which should be formatted (not an IAssertionGroup). methodObject - The method object which contains inter alia the sb to with the result will be appended.

Exceptions

UnsupportedOperationException - in case this IAssertionFormatter cannot format the given assertion (canFormat returns false) or if assertion is an IAssertionGroup.