TestRule
TemporaryFolder
public abstract class ExternalResource extends java.lang.Object implements TestRule
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); } }
Constructor | Description |
---|---|
ExternalResource() |
Modifier and Type | Method | Description |
---|---|---|
protected void |
after() |
Override to tear down your specific external resource.
|
Statement |
apply(Statement base,
Description description) |
Modifies the method-running
Statement to implement this
test-running rule. |
protected void |
before() |
Override to set up your specific external resource.
|
public Statement apply(Statement base, Description description)
TestRule
Statement
to implement this
test-running rule.apply
in interface TestRule
base
- The Statement
to be modifieddescription
- A Description
of the test implemented in base
base
,
a wrapper around base
, or a completely new Statement.protected void before() throws java.lang.Throwable
java.lang.Throwable
protected void after()