本文整理汇总了Java中org.junit.runners.model.Statement.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.evaluate方法的具体用法?Java Statement.evaluate怎么用?Java Statement.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.junit.runners.model.Statement
的用法示例。
在下文中一共展示了Statement.evaluate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
public Statement apply(final Statement base, FrameworkMethod method, Object target) {
sampleName = getSampleName(method);
return new Statement() {
@Override
public void evaluate() throws Throwable {
if (sampleName != null) {
String hintForMissingSample = String.format("If '%s' is a new sample, try running 'gradle intTestImage'.", sampleName);
TestFile srcDir = new IntegrationTestBuildContext().getSamplesDir().file(sampleName).assertIsDir(hintForMissingSample);
logger.debug("Copying sample '{}' to test directory.", sampleName);
srcDir.copyTo(getDir());
} else {
logger.debug("No sample specified for this test, skipping.");
}
base.evaluate();
}
};
}
示例2: apply
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
server.start();
retrofit = new Retrofit.Builder()
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(new GsonService().getGsonConverterFactory())
.baseUrl(server.url("").toString())
.client(new HttpService(context).getHttpClient())
.build();
base.evaluate();
server.shutdown();
}
};
}
示例3: apply
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
// save the instance config
LOG.debug("Saving instance config {}", instanceConfig.getClass());
instanceConfig.save();
// Call any actions if any
for (Action action : actions) {
LOG.debug("Calling action {}", action.getClass());
action.call();
}
// run the base statement
LOG.debug("Running base statement");
base.evaluate();
if (withRestore) {
LOG.debug("Restoring instance config {}", instanceConfig.getClass());
instanceConfig.restore();
}
}
};
}
示例4: apply
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
System.getProperties().putAll(customProperties);
resetTempDirLocation();
try {
base.evaluate();
} finally {
System.setProperties(properties);
resetTempDirLocation();
}
}
};
}
示例5: apply
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxAndroidPlugins.reset();
RxAndroidPlugins.setInitMainThreadSchedulerHandler(scheduler -> Schedulers.trampoline());
RxJavaPlugins.reset();
RxJavaPlugins.setIoSchedulerHandler(schedulerCallable -> Schedulers.trampoline());
base.evaluate();
RxAndroidPlugins.reset();
RxJavaPlugins.reset();
}
};
}
示例6: expect_exceptionThrownButExpectingDifferentError_shouldFail
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Test
public void expect_exceptionThrownButExpectingDifferentError_shouldFail() throws Throwable {
// given
Statement originalStatement = new Statement() {
@Override
public void evaluate() throws Throwable {
Single.just("bar")
.map(s -> { throw new Exception("foo"); })
.subscribe();
}
};
ExpectedUncaughtException uncaughtThrown = ExpectedUncaughtException.none();
uncaughtThrown.expect(Exception.class);
uncaughtThrown.expectMessage("foo");
Statement statement = uncaughtThrown.apply(originalStatement, description);
thrown.expect(AssertionError.class);
thrown.expectMessage("Uncaught exception occurred, " +
"but is different than expected:\n" +
"Expected: <java.lang.Exception>\n" +
" but: was <io.reactivex.exceptions.OnErrorNotImplementedException>");
// when
statement.evaluate();
// then should fail
}
示例7: apply
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxAndroidPlugins.reset();
RxAndroidPlugins.setInitMainThreadSchedulerHandler(mRxAndroidSchedulersHook);
RxJavaPlugins.reset();
RxJavaPlugins.setIoSchedulerHandler(mRxJavaImmediateScheduler);
RxJavaPlugins.setNewThreadSchedulerHandler(mRxJavaImmediateScheduler);
base.evaluate();
RxAndroidPlugins.reset();
RxJavaPlugins.reset();
}
};
}
示例8: statementStartsAndStops
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Test public void statementStartsAndStops() throws Throwable {
final AtomicBoolean called = new AtomicBoolean();
Statement statement = server.apply(new Statement() {
@Override public void evaluate() throws Throwable {
called.set(true);
server.url("/").url().openConnection().connect();
}
}, Description.EMPTY);
statement.evaluate();
assertTrue(called.get());
try {
server.url("/").url().openConnection().connect();
fail();
} catch (ConnectException expected) {
}
}
示例9: statement
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
private Statement statement(final Statement base, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
Throwable caughtThrowable = null;
// implement retry logic here
for (int i = 0; i < retryCount; i++) {
try {
base.evaluate();
return;
} catch (Throwable t) {
caughtThrowable = t;
log.error(description.getDisplayName() + ": run " + (i+1) + " failed");
}
}
log.info(description.getDisplayName() + ": giving up after " + retryCount + " failures");
if (caughtThrowable != null) {
throw caughtThrowable;
}
}
};
}
示例10: apply
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxAndroidPlugins.getInstance().reset();
RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
RxJavaPlugins.getInstance().reset();
RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook);
base.evaluate();
RxAndroidPlugins.getInstance().reset();
RxJavaPlugins.getInstance().reset();
}
};
}
示例11: apply
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, FrameworkMethod method, final Object target) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
MockitoAnnotations.initMocks(target);
try {
base.evaluate();
} finally {
Mockito.validateMockitoUsage();
}
}
};
}
示例12: apply
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
resetState();
try {
base.evaluate();
} finally {
resetState();
}
}
};
}
示例13: apply
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
active = true;
diagnostics = new ArrayList<Diagnostic<? extends JavaFileObject>>();
boolean captureDiagnosticsStart = captureDiagnostics;
try {
File testRoot = methodNameDir(classNameDir(rootDirectory(), description.getClassName()),
description.getMethodName());
generateDir = new File(testRoot, "generate");
compileDir = new File(testRoot, "compile");
base.evaluate();
} finally {
generateDir = null;
compileDir = null;
classLoader = null;
sourceDirInitialized = false;
classesDirInitialized = false;
captureDiagnostics = captureDiagnosticsStart;
diagnostics = null;
active = false;
}
}
};
}
示例14: apply
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override public void evaluate() throws Throwable {
base.evaluate();
for (RecordingSingleObserver<?> subscriber : subscribers) {
subscriber.assertNoEvents();
}
}
};
}
示例15: apply
import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
try {
setupDaggerTestComponentInApplication();
base.evaluate();
} finally {
mTestComponent = null;
}
}
};
}