當前位置: 首頁>>代碼示例>>Java>>正文


Java Description類代碼示例

本文整理匯總了Java中org.junit.runner.Description的典型用法代碼示例。如果您正苦於以下問題:Java Description類的具體用法?Java Description怎麽用?Java Description使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Description類屬於org.junit.runner包,在下文中一共展示了Description類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: statement

import org.junit.runner.Description; //導入依賴的package包/類
private Statement statement(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            Throwable caughtThrowable = null;
            for (int i = 0; i < retryCount; i++) {
                try {
                    base.evaluate();
                    return;
                } catch (Throwable t) {
                    caughtThrowable = t;
                    System.err.println(description.getDisplayName() + ": run " + (i + 1) + " failed");
                }
            }
            System.err.println(description.getDisplayName() + ": giving up after " + retryCount + " failures");
            throw caughtThrowable;
        }
    };
}
 
開發者ID:Adyen,項目名稱:adyen-android,代碼行數:20,代碼來源:RetryTest.java

示例2: statement

import org.junit.runner.Description; //導入依賴的package包/類
private Statement statement(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            Throwable caughtThrowable = null;
            for (int i = 0; i < retryCount; i++) {
                try {
                    base.evaluate();
                    return;
                } catch (Throwable t) {
                    caughtThrowable = t;
                    System.err.println(description.getDisplayName() + ": run " + (i+1) + " failed");
                }
            }
            System.err.println(description.getDisplayName() + ": giving up after " + retryCount + " failures");
            throw caughtThrowable;
        }
    };
}
 
開發者ID:IrrilevantHappyLlamas,項目名稱:Runnest,代碼行數:20,代碼來源:EspressoTest.java

示例3: starting

import org.junit.runner.Description; //導入依賴的package包/類
@Override
protected void starting(Description description) {
  if (restoreHandlers) {
    // https://github.com/ReactiveX/RxAndroid/pull/358
    //            originalInitMainThreadInitHandler =
    // RxAndroidPlugins.getInitMainThreadScheduler();
    //            originalMainThreadHandler = RxAndroidPlugins.getMainThreadScheduler();
  }
  RxAndroidPlugins.reset();
  RxAndroidPlugins.setInitMainThreadSchedulerHandler(
      new Function<Callable<Scheduler>, Scheduler>() {
        @Override
        public Scheduler apply(Callable<Scheduler> schedulerCallable) throws Exception {
          return delegatingMainThreadScheduler;
        }
      });
  RxAndroidPlugins.setMainThreadSchedulerHandler(
      new Function<Scheduler, Scheduler>() {
        @Override
        public Scheduler apply(Scheduler scheduler) throws Exception {
          return delegatingMainThreadScheduler;
        }
      });
}
 
開發者ID:uber,項目名稱:RIBs,代碼行數:25,代碼來源:AndroidSchedulersRule.java

示例4: testRunStarted

import org.junit.runner.Description; //導入依賴的package包/類
@Override public void testRunStarted(Description description) throws Exception {
  System.err.println("Installing aggressive uncaught exception handler");
  oldDefaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
  Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
    @Override public void uncaughtException(Thread thread, Throwable throwable) {
      StringWriter errorText = new StringWriter(256);
      errorText.append("Uncaught exception in OkHttp thread \"");
      errorText.append(thread.getName());
      errorText.append("\"\n");
      throwable.printStackTrace(new PrintWriter(errorText));
      errorText.append("\n");
      if (lastTestStarted != null) {
        errorText.append("Last test to start was: ");
        errorText.append(lastTestStarted.getDisplayName());
        errorText.append("\n");
      }
      System.err.print(errorText.toString());
      System.exit(-1);
    }
  });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:InstallUncaughtExceptionHandlerListener.java

示例5: apply

import org.junit.runner.Description; //導入依賴的package包/類
@Override
public Statement apply(final Statement statement, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            long startTime = System.currentTimeMillis();
            try {
                if (printPre) {
                    System.out.println("Enter -->> " + description.getTestClass() + "#" + description.getMethodName());
                }
                statement.evaluate();
            } finally {
                if (printPost) {
                    long finishTime = System.currentTimeMillis() - startTime;
                    System.out.println("Leave -->> " + description.getMethodName() + ", elapsed(ms): " + finishTime);
                }
            }
        }
    };
}
 
開發者ID:altiplanogao,項目名稱:io-comparison,代碼行數:21,代碼來源:PrintEntrance.java

示例6: apply

import org.junit.runner.Description; //導入依賴的package包/類
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            RxJavaPlugins.setIoSchedulerHandler(scheduler ->
                    Schedulers.trampoline());
            RxJavaPlugins.setComputationSchedulerHandler(scheduler ->
                    Schedulers.trampoline());
            RxJavaPlugins.setNewThreadSchedulerHandler(scheduler ->
                    Schedulers.trampoline());
            try {
                base.evaluate();
            } finally {
                RxJavaPlugins.reset();
            }
        }
    };
}
 
開發者ID:OlegDokuka,項目名稱:reactive-playing,代碼行數:20,代碼來源:WordServiceWithRuleTest.java

示例7: statementStartsAndStops

import org.junit.runner.Description; //導入依賴的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) {
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:MockWebServerTest.java

示例8: apply

import org.junit.runner.Description; //導入依賴的package包/類
@Override
public Statement apply(final Statement base, Description description) {
    final RunTestWithRemoteService annotation = description.getAnnotation(RunTestWithRemoteService.class);
    if (annotation == null) {
        return base;
    }
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            before(annotation.remoteService());
            try {
                base.evaluate();
            } finally {
                if (!annotation.onLooperThread()) {
                    after();
                }
            }
        }
    };
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:RunWithRemoteService.java

示例9: starting

import org.junit.runner.Description; //導入依賴的package包/類
@Override
public final void starting(Description description)
{
    this.description = description;
    if (!this.isRebasing)
    {
        this.expectedResultsFuture = EXPECTED_RESULTS_LOADER_EXECUTOR.submit(new Callable<ExpectedResults>()
        {
            @Override
            public ExpectedResults call() throws Exception
            {
                return ExpectedResultsCache.getExpectedResults(expectedResultsLoader, getExpectedFile());
            }
        });
    }
    this.lifecycleEventHandler.onStarted(description);
}
 
開發者ID:goldmansachs,項目名稱:tablasco,代碼行數:18,代碼來源:TableVerifier.java

示例10: apply

import org.junit.runner.Description; //導入依賴的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();
            }
        }
    };
}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-testing-rules,代碼行數:26,代碼來源:InstanceConfigRule.java

示例11: apply

import org.junit.runner.Description; //導入依賴的package包/類
@Override
public Statement apply(final Statement base, Description description) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      RxJavaPlugins.reset();
      RxJavaPlugins.setIoSchedulerHandler(scheduler -> Schedulers.trampoline());
      RxJavaPlugins.setComputationSchedulerHandler(scheduler -> Schedulers.trampoline());
      RxJavaPlugins.setNewThreadSchedulerHandler(scheduler -> Schedulers.trampoline());

      try {
        base.evaluate();
      } finally {
        RxJavaPlugins.reset();
      }
    }
  };
}
 
開發者ID:talenguyen,項目名稱:Architecture,代碼行數:19,代碼來源:ImmediateSchedulersRule.java

示例12: testRunStarted

import org.junit.runner.Description; //導入依賴的package包/類
/**
 * Called before any tests have been run.
 *
 * @param description
 *            describes the tests to be run
 */
@Override
public void testRunStarted(Description description) throws Exception {
	Display.getDefault().syncExec(new Runnable() {
		@Override
		public void run() {

			IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
			try {
				N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView(
						N4IDEXpectView.ID);
				view.notifySessionStarted(description);
			} catch (PartInitException e) {
				N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
			}
		}
	});
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:24,代碼來源:N4IDEXpectRunListener.java

示例13: testIgnored

import org.junit.runner.Description; //導入依賴的package包/類
/**
 * Called when a test will not be run, generally because a test method is annotated with {@link org.junit.Ignore}.
 *
 * @param description
 *            describes the test that will not be run
 */
@Override
public void testIgnored(Description description) throws Exception {
	Display.getDefault().syncExec(new Runnable() {
		@Override
		public void run() {

			IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
			try {
				N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView(
						N4IDEXpectView.ID);
				view.notifyIgnoredExecutionOf(description);
			} catch (PartInitException e) {
				N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
			}
		}
	});
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:24,代碼來源:N4IDEXpectRunListener.java

示例14: after

import org.junit.runner.Description; //導入依賴的package包/類
/**
 * Closes the webDriver which was created in this rule. Takes care if there is an exception while
 * closing the webDriver.
 */
@Override
protected void after(Description description, Throwable testFailure) throws Throwable {
    super.after(description, testFailure);
    if (getWebDriver() != null) {
        try {
            getWebDriver().quit();
        } catch (Exception ex) {
            if (!ex.getMessage().contains("It may have died")) {
                throw ex;
            }
            LOGGER.info("Error while closing browser. This error cannot be avoided somehow. " +
                    "This is not a big problem.", ex);
        }
        webDriver = null;
    }
}
 
開發者ID:willhaben,項目名稱:willtest,代碼行數:21,代碼來源:AbstractSeleniumProvider.java

示例15: apply

import org.junit.runner.Description; //導入依賴的package包/類
@Override
public Statement apply(Statement base, Description description) {
    return new Statement() {
        public void evaluate() throws Throwable {
            base.evaluate();
            assertAll();
        }
    };
}
 
開發者ID:arquillian,項目名稱:smart-testing,代碼行數:10,代碼來源:SmartTestingSoftAssertions.java


注:本文中的org.junit.runner.Description類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。