use of org.junit.runners.model.Statement in project gradle by gradle.
the class RedirectStdIn method apply.
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
final InputStream originalStdIn = System.in;
initPipe();
System.setIn(emulatedSystemIn);
try {
base.evaluate();
} finally {
System.setIn(originalStdIn);
closePipe();
}
}
};
}
use of org.junit.runners.model.Statement in project gradle by gradle.
the class CustomRunner method methodBlock.
@Override
protected Statement methodBlock(final FrameworkMethod method) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
if (isClassUnderTestLoaded) {
throw new RuntimeException("Test Class should not be loaded");
}
final HelperTestRunner helperTestRunner = new HelperTestRunner(bootstrappedTestClass);
final Method bootstrappedMethod = bootstrappedTestClass.getMethod(method.getName());
final Statement statement = helperTestRunner.methodBlock(new FrameworkMethod(bootstrappedMethod));
statement.evaluate();
}
};
}
use of org.junit.runners.model.Statement in project hazelcast by hazelcast.
the class AbstractHazelcastClassRunner method methodBlock.
@Override
protected Statement methodBlock(FrameworkMethod method) {
Statement statement = super.methodBlock(method);
Repeat repeatable = getRepeatable(method);
if (repeatable == null || repeatable.value() < 2) {
return statement;
}
return new TestRepeater(statement, method.getMethod(), repeatable.value());
}
use of org.junit.runners.model.Statement in project alchemy-test by SirWellington.
the class AlchemyTestRunner method withBefores.
@Override
protected Statement withBefores(FrameworkMethod method, Object target, Statement statement) {
Statement superStatement = super.withBefores(method, target, statement);
return new Statement() {
@Override
public void evaluate() throws Throwable {
if (shouldInitMocks) {
MockitoAnnotations.initMocks(target);
}
TestClassInjectors.populateGeneratedFields(getTestClass(), target);
superStatement.evaluate();
}
};
}
use of org.junit.runners.model.Statement in project beam by apache.
the class TestExecutorsTest method testSuccessfulTermination.
@Test
public void testSuccessfulTermination() throws Throwable {
ExecutorService service = Executors.newSingleThreadExecutor();
final TestExecutorService testService = TestExecutors.from(() -> service);
final AtomicBoolean taskRan = new AtomicBoolean();
testService.apply(new Statement() {
@Override
public void evaluate() throws Throwable {
testService.submit(() -> taskRan.set(true));
}
}, null).evaluate();
assertTrue(service.isTerminated());
assertTrue(taskRan.get());
}
Aggregations