org.junit.rules.TestRulepublic final class AdditionalFailureInfo extends Object implements org.junit.rules.TestRule
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 Truth.assertWithMessage(String) 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).
| Constructor | Description |
|---|---|
AdditionalFailureInfo() |
| Modifier and Type | Method | Description |
|---|---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
|
void |
setInfo(String info) |
Set the additional info to be added to any test failures.
|
public void setInfo(@Nullable
String info)
null to skip adding any
additional info.
Can be called from any thread.
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
apply in interface org.junit.rules.TestRule