当前位置: 首页>>代码示例>>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;未经允许,请勿转载。