AdditionalFailureInfo


@UnstableApi
class AdditionalFailureInfo : TestRule


A JUnit Rule that attaches additional info to any errors/exceptions thrown by the test.

This is useful for tests where the line-number from a stacktrace doesn't provide enough detail about the failure, for example when an assertion fails inside a loop.

This can be preferable to many calls to assertWithMessage because it will also add info to errors/exceptions that bubble out from the system-under-test.

Includes special handling for AssertionError to ensure that test failures are correctly distinguished from test errors (all other errors/exceptions).

Summary

Public constructors

Public functions

Statement!
apply(base: Statement!, description: Description!)
Unit
setInfo(info: String?)

Sets the additional info to be added to any test failures.

Public constructors

AdditionalFailureInfo

AdditionalFailureInfo()

Public functions

apply

fun apply(base: Statement!, description: Description!): Statement!

setInfo

fun setInfo(info: String?): Unit

Sets the additional info to be added to any test failures. Pass null to skip adding any additional info.

Can be called from any thread.