T - The type of the object managed by this rule.public final class CloseableRule<T extends AutoCloseable> extends Object implements org.junit.rules.TestRule
TestRule that will automatically close an object after tests.
This makes it slightly nicer than having @After methods for each resource to
close. It makes most sense when a test instantiate multiple AutoCloseable resources.| Modifier and Type | Method and Description |
|---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
static <T extends AutoCloseable> |
autoClose(T closeable) |
T |
get() |
public static <T extends AutoCloseable> CloseableRule<T> autoClose(T closeable)
public T get()
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 © 2019. All rights reserved.