本文整理匯總了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;
}
}
};
}