java.lang.Object | |
↳ | org.junit.rules.ExternalResource |
![]() |
A base class for Rules (like TemporaryFolder) that set up an external resource before a test (a file, socket, server, database connection, etc.), and guarantee to tear it down afterward:
public static class UsesExternalResource { Server myServer= new Server(); @Rule public ExternalResource resource= new ExternalResource() { @Override protected void before() throws Throwable { myServer.connect(); }; @Override protected void after() { myServer.disconnect(); }; }; @Test public void testFoo() { new Client().run(myServer); } }
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Modifies the method-running
Statement to implement an additional
test-running rule. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Override to tear down your specific external resource.
| |||||||||||
Override to set up your specific external resource.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Modifies the method-running Statement
to implement an additional
test-running rule.
base | The Statement to be modified |
---|---|
method | The method to be run |
target | The object on with the method will be run. |
base
,
a wrapper around base
, or a completely new Statement.
Override to tear down your specific external resource.
Override to set up your specific external resource.
setup fails (which will disable after
|
|
Throwable |