public class SharedObjectCleaner
extends org.junit.rules.ExternalResource
Shared
class fields.
Using this,
Example:
// operator class with shared class field
public abstract class SomeOperator {
// shared value container
static final Shared<Hoge> SHARED = new Shared<Hoge>() {
...
}
...
}
// test class
public class SomeOperatorTest {
// auto-remove shared value containers in SomeOperator class
@Rule
public final SharedObjectCleaner cleaner = new SharedObjectCleaner()
.add(SomeOperator.class);
@Test
public void test() {
...
}
}
Constructor and Description |
---|
SharedObjectCleaner() |
Modifier and Type | Method and Description |
---|---|
SharedObjectCleaner |
add(Class<?>... classes)
Registers shared objects declared in class fields.
|
SharedObjectCleaner |
add(Shared<?>... objects)
Registers
Shared objects. |
protected void |
after() |
protected void |
before() |
public SharedObjectCleaner add(Shared<?>... objects)
Shared
objects.objects
- shared objectspublic final SharedObjectCleaner add(Class<?>... classes)
classes
- target classes which has shared class fieldsprotected final void before()
before
in class org.junit.rules.ExternalResource
protected final void after()
after
in class org.junit.rules.ExternalResource
Copyright © 2011–2019 Asakusa Framework Team. All rights reserved.