public class TestFailureAwareRule extends Object implements org.junit.rules.TestRule
ExternalResource, but gives possibility to do something in case of errors.
Also if there is a test error, this class takes care, that errors from its implementations are added as
suppressed exceptions to the test error to avoid loosing that original problem. If the test was successful, but
after(Description, Throwable) throws an error, then the test will fail.| Constructor and Description |
|---|
TestFailureAwareRule()
Just to make sure, that this class will not be instantiated, only its children
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
after(org.junit.runner.Description description,
Throwable testFailure)
Called after all tests always.
|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
protected void |
before(org.junit.runner.Description description)
Can do something before a test.
|
protected void |
onError(org.junit.runner.Description description,
Throwable testFailure)
Called if the test has thrown an error.
|
public TestFailureAwareRule()
protected void before(org.junit.runner.Description description)
throws Throwable
description - junit test description objectThrowable - any error from the testprotected void after(org.junit.runner.Description description,
Throwable testFailure)
throws Throwable
description - junit test description objecttestFailure - in case of failed test it contains an exception. Otherwise nullThrowable - if testFailure is null, it will fly, if testFailure is not null,
it will be added to that as suppressed exception. See Throwable.addSuppressed(Throwable)protected void onError(org.junit.runner.Description description,
Throwable testFailure)
throws Throwable
description - junit test description objecttestFailure - any error from the testThrowable - this will be added to testFailure as suppressed exception.
See Throwable.addSuppressed(Throwable)public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
apply in interface org.junit.rules.TestRuleCopyright © 2018 willhaben internet service GmbH & Co KG. All rights reserved.