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


Java Result類代碼示例

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


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

示例1: doRun

import org.junit.runner.Result; //導入依賴的package包/類
public Result doRun(Test suite, boolean wait) {
    MarathonTestRunner runner = new MarathonTestRunner();
    runReportDir = argProcessor.getReportDir();
    String resultsDir = new File(runReportDir, "results").getAbsolutePath();
    if (runReportDir != null) {
        System.setProperty(Constants.PROP_REPORT_DIR, runReportDir);
        System.setProperty(Constants.PROP_IMAGE_CAPTURE_DIR, runReportDir);
        System.setProperty("allure.results.directory", resultsDir);
        runner.addListener(new AllureMarathonRunListener());
    }
    runner.addListener(new TextListener(System.out));
    Result result = runSuite(suite, runner);
    MarathonTestCase.reset();
    if (runReportDir != null && !argProcessor.isSkipreports()) {
        AllureUtils.launchAllure(false, resultsDir, new File(runReportDir, "reports").getAbsolutePath());
    }
    return result;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,代碼來源:TestRunner.java

示例2: firstShouldBeFirstBeforeLastAfter

import org.junit.runner.Result; //導入依賴的package包/類
@Test
public void firstShouldBeFirstBeforeLastAfter() {
  Result result = TestRunner.runTest(ThreeRules.class);

  assertThat(result.wasSuccessful()).isTrue();

  assertThat(counter.get()).isEqualTo(9);

  assertThat(invocations[0].beforeInvocation).isEqualTo(1);
  assertThat(invocations[1].beforeInvocation).isEqualTo(2);
  assertThat(invocations[2].beforeInvocation).isEqualTo(3);

  assertThat(invocations[0].testInvocation).isEqualTo(4);
  assertThat(invocations[1].testInvocation).isEqualTo(5);
  assertThat(invocations[2].testInvocation).isEqualTo(6);

  assertThat(invocations[2].afterInvocation).isEqualTo(7);
  assertThat(invocations[1].afterInvocation).isEqualTo(8);
  assertThat(invocations[0].afterInvocation).isEqualTo(9);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:21,代碼來源:RuleListTest.java

示例3: main

import org.junit.runner.Result; //導入依賴的package包/類
public static void main(String[] args) {
  final Result result =
      JUnitCore.runClasses(
          codeu.chat.common.SecretTest.class,
          codeu.chat.relay.ServerTest.class,
          codeu.chat.server.BasicControllerTest.class,
          codeu.chat.server.RawControllerTest.class,
          codeu.chat.util.TimeTest.class,
          codeu.chat.util.UuidTest.class,
          codeu.chat.util.store.StoreTest.class
      );
   for (final Failure failure : result.getFailures()) {
      System.out.println(failure.toString());
   }
   System.out.println(result.wasSuccessful());
}
 
開發者ID:google,項目名稱:codeu_project_2017,代碼行數:17,代碼來源:TestRunner.java

示例4: testRunFinished

import org.junit.runner.Result; //導入依賴的package包/類
/**
*
* @see org.junit.runner.notification.RunListener#testRunFinished(org.junit.runner.Result)
*/
@Override
public void testRunFinished( Result result ) throws Exception {

    if (log.isDebugEnabled()) {
        log.debug("testRunFinished(): result " + "| failure count: " + result.getFailureCount()
                  + "| ignored count: " + result.getIgnoreCount() + "| tests run count: "
                  + result.getRunCount() + "| Run time: " + result.getRunTime() + "ms.");
    }
    if (lastSuiteName != null) {
        logger.endSuite();
        lastSuiteName = null; // Run finished. A lastSuiteName should not be visible between runs
    }
    // end the run
    logger.endRun();
    super.testRunFinished(result);
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:21,代碼來源:AtsJunitTestListener.java

示例5: main

import org.junit.runner.Result; //導入依賴的package包/類
public static void main(String[] args) {
  final Result result =
      JUnitCore.runClasses(
          codeu.chat.common.SecretTest.class,
          codeu.chat.relay.ServerTest.class,
          codeu.chat.server.BasicControllerTest.class,
          codeu.chat.server.RawControllerTest.class,
          codeu.chat.util.TimeTest.class,
          codeu.chat.util.TokenizerTest.class,
          codeu.chat.util.UuidTest.class,
          codeu.chat.util.store.StoreTest.class
      );
   for (final Failure failure : result.getFailures()) {
      System.out.println(failure.toString());
   }
   System.out.println(result.wasSuccessful());
}
 
開發者ID:Pandarati,項目名稱:CodeU-Summer-2017,代碼行數:18,代碼來源:TestRunner.java

示例6: runTestSuiteAgainst

import org.junit.runner.Result; //導入依賴的package包/類
/**
 * Creates and runs a JUnit test runner for testSuite.
 *
 * @param testSuite the class defining test cases to run
 * @param view a UI component to report test failures to
 * @return the counts of failures and total test cases.
 */
static RunResult runTestSuiteAgainst(Class testSuite, View view)
{
    if(testSuite == null)
        throw new NullPointerException("testSuite");

    if(view == null)
        throw new NullPointerException("view");

    Result result = new JUnitCore().run(testSuite);

    if (result.getFailureCount() > 0)
    {
        for (Failure f : result.getFailures())
            view.declarePassProgramTestFailure(f.getTrace());
    }


    return new RunResult(result.getFailureCount(), result.getRunCount());
}
 
開發者ID:capergroup,項目名稱:bayou,代碼行數:27,代碼來源:TestSuiteRunner.java

示例7: main

import org.junit.runner.Result; //導入依賴的package包/類
/**
 * .
 * @param args .
 * @throws ClassNotFoundException .
 */
public static void main(String... args) throws ClassNotFoundException {
    int retCode = 0;
    String resultMessage = "SUCCESS";
    String[] classAndMethod = args[0].split("#");
    Request request = Request.method(Class.forName(classAndMethod[0]),
            classAndMethod[1]);

    Result result = new JUnitCore().run(request);
    if (!result.wasSuccessful()) {
        retCode = 1;
        resultMessage = "FAILURE";
    }
    System.out.println(resultMessage);
    System.exit(retCode);
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:21,代碼來源:SingleJUnitTestRunner.java

示例8: failsWithExpectedTimeoutButWrongError

import org.junit.runner.Result; //導入依賴的package包/類
@Test
public void failsWithExpectedTimeoutButWrongError() {
  Result result = TestRunner.runTest(FailsWithExpectedTimeoutButWrongError.class);

  assertThat(result.wasSuccessful()).isFalse();

  List<Failure> failures = result.getFailures();
  assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);

  Failure failure = failures.get(0);
  String expectedMessage = "\n"
      + "Expected: (an instance of java.util.concurrent.TimeoutException and exception with message a string containing \"this is a message for FailsWithExpectedTimeoutButWrongError\")"
      + "\n" + "     "
      + "but: an instance of java.util.concurrent.TimeoutException <java.lang.NullPointerException> is a java.lang.NullPointerException";
  assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class)
      .hasMessageContaining(expectedMessage);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:18,代碼來源:ExpectedTimeoutRuleTest.java

示例9: assertResultHasNoFailures

import org.junit.runner.Result; //導入依賴的package包/類
/**
 * Checks that result has no failures.
 * Print all the failures in error message if there are any.
 */
public static void assertResultHasNoFailures(Result result) {
    List<Failure> failures = result.getFailures();
    assertThat(failures)
            .as("No failures expected. Failures: %s",
                    failures.stream()
                            .map(ResultAssertions::formFailureDescription)
                            .collect(Collectors.toList()))
            .isEmpty();
}
 
開發者ID:SeriyBg,項目名稱:junit-easy-tools,代碼行數:14,代碼來源:ResultAssertions.java

示例10: testBrokenCategoryAndParameterized

import org.junit.runner.Result; //導入依賴的package包/類
@Test
public void testBrokenCategoryAndParameterized() {
  Request request = Request.aClass(BrokenCategoryClass.class);
  ExposedParameterized runner = (ExposedParameterized) request.getRunner();
  request = request.filterWith(new CategoryFilter(
      (ExposedBlockJUnit4ClassRunnerWithParameters) runner.getChildren().get(0)));
  Result result = new JUnitCore().run(request);
  assertEquals(
      "Yeah!! This might actually mean we've upgraded to JUnit 4.13. Hurry up already and delete this hack.",
      1, result.getRunCount());
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:12,代碼來源:CategoryWithParameterizedRunnerFactoryTest.java

示例11: failsOnSecondAttempt

import org.junit.runner.Result; //導入依賴的package包/類
@Test
public void failsOnSecondAttempt() {
  Result result = TestRunner.runTest(FailsOnSecondAttempt.class);

  assertThat(result.wasSuccessful()).isFalse();

  List<Failure> failures = result.getFailures();
  assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);

  Failure failure = failures.get(0);
  assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class)
      .hasMessage(FailsOnSecondAttempt.message);
  assertThat(FailsOnSecondAttempt.count).isEqualTo(2);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:15,代碼來源:RetryRuleGlobalWithExceptionTest.java

示例12: main

import org.junit.runner.Result; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    Result result = JUnitCore.runClasses(Bug_for_Next.class);
    for (Failure fail : result.getFailures()) {
        System.out.println(fail.toString());
    }
    if (result.wasSuccessful()) {
        System.out.println("All tests finished successfully...");
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:Bug_for_Next.java

示例13: main

import org.junit.runner.Result; //導入依賴的package包/類
public static void main(String[] args) {
  final Result result =
      JUnitCore.runClasses(
          codeu.chat.common.SecretTest.class,
          codeu.chat.relay.ServerTest.class,
          codeu.chat.server.BasicControllerTest.class,
          codeu.chat.server.RawControllerTest.class,
          codeu.chat.util.TimeTest.class,
          codeu.chat.util.UuidTest.class,
          codeu.chat.util.store.StoreTest.class,
          codeu.chat.util.TokenizerTest.class,
          codeu.chat.server.ControllerTest.class
      );

   System.out.println("\n===================== Test Status ====================");
   System.out.println(String.format("%d tests run.", result.getRunCount()));

   if (result.wasSuccessful()) {
     System.out.println("All tests passed.");
   } else {
     System.out.println(String.format("%d tests failed.", result.getFailureCount()));
     System.out.println("\nFailures:");
     for (final Failure failure : result.getFailures()) {
        System.out.println(failure.toString());
     }
   }

   System.out.println("======================================================\n");
   System.exit(result.wasSuccessful() ? 0 : -1);
}
 
開發者ID:EVelez79,項目名稱:CodeU-ProjectGroup6,代碼行數:31,代碼來源:TestRunner.java

示例14: failingTestShouldFailOneTimeWhenRepeatIsThree

import org.junit.runner.Result; //導入依賴的package包/類
@Test
public void failingTestShouldFailOneTimeWhenRepeatIsThree() {
  Result result = TestRunner.runTest(FailingTestShouldFailOneTimeWhenRepeatIsThree.class);

  assertThat(result.wasSuccessful()).isFalse();

  List<Failure> failures = result.getFailures();
  assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);

  Failure failure = failures.get(0);
  assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class)
      .hasMessage(ASSERTION_ERROR_MESSAGE);
  assertThat(FailingTestShouldFailOneTimeWhenRepeatIsThree.count).isEqualTo(1);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:15,代碼來源:RepeatRuleTest.java

示例15: passesOnThirdAttempt

import org.junit.runner.Result; //導入依賴的package包/類
@Test
public void passesOnThirdAttempt() {
  Result result = TestRunner.runTest(PassesOnThirdAttempt.class);

  assertThat(result.wasSuccessful()).isTrue();
  assertThat(PassesOnThirdAttempt.count).isEqualTo(3);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:8,代碼來源:RetryRuleLocalWithExceptionTest.java


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