当前位置: 首页>>代码示例>>Java>>正文


Java Result.getFailures方法代码示例

本文整理汇总了Java中org.junit.runner.Result.getFailures方法的典型用法代码示例。如果您正苦于以下问题:Java Result.getFailures方法的具体用法?Java Result.getFailures怎么用?Java Result.getFailures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.junit.runner.Result的用法示例。


在下文中一共展示了Result.getFailures方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: zeroValueShouldThrowIllegalArgumentException

import org.junit.runner.Result; //导入方法依赖的package包/类
@Test
public void zeroValueShouldThrowIllegalArgumentException() {
  Result result = TestRunner.runTest(ZeroValueShouldThrowIllegalArgumentException.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(IllegalArgumentException.class)
      .hasMessage("Repeat value must be a positive integer");
  assertThat(ZeroValueShouldThrowIllegalArgumentException.count).isEqualTo(0);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:RepeatRuleTest.java

示例6: failsWithoutExpectedTimeoutException

import org.junit.runner.Result; //导入方法依赖的package包/类
@Test
public void failsWithoutExpectedTimeoutException() {
  Result result = TestRunner.runTest(FailsWithoutExpectedTimeoutException.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("Expected test to throw (an instance of " + TimeoutException.class.getName()
          + " and exception with message a string containing \""
          + FailsWithoutExpectedTimeoutException.message + "\")");
}
 
开发者ID:ampool,项目名称:monarch,代码行数:16,代码来源:ExpectedTimeoutRuleTest.java

示例7: main

import org.junit.runner.Result; //导入方法依赖的package包/类
public static void main(String[] args) throws ClassNotFoundException {
	Result res = JUnitCore.runClasses(Class.forName("formatsi.FormatTest"));
	for (Failure fail : res.getFailures()) {
		System.out.println(String.format("Test failed: %s", fail.getTestHeader()));
	}

	System.out.println("Messages:");
	printMessages();
}
 
开发者ID:Ativelox,项目名称:JavaCourse,代码行数:10,代码来源:Main.java

示例8: failsOnThirdAttempt

import org.junit.runner.Result; //导入方法依赖的package包/类
@Test
public void failsOnThirdAttempt() {
  Result result = TestRunner.runTest(FailsOnThirdAttempt.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(FailsOnThirdAttempt.message);
  assertThat(FailsOnThirdAttempt.count).isEqualTo(3);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:RetryRuleLocalWithExceptionTest.java

示例9: main

import org.junit.runner.Result; //导入方法依赖的package包/类
public static void main(String[] args) {
	Result result = JUnitCore.runClasses(BankDetailsJunitTest.class);
	for (Failure failure : result.getFailures()) {
		System.out.println(failure.toString());
	}
	System.out.println("==========================================================================");
	System.out.println(result.wasSuccessful());
}
 
开发者ID:arjunnayak0705,项目名称:java-indian-bank-api-wrapper,代码行数:9,代码来源:TestRunner.java

示例10: 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

示例11: failsWithoutExpectedException

import org.junit.runner.Result; //导入方法依赖的package包/类
@Test
public void failsWithoutExpectedException() {
  Result result = TestRunner.runTest(FailsWithoutExpectedException.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("Expected test to throw an instance of " + TimeoutException.class.getName());
}
 
开发者ID:ampool,项目名称:monarch,代码行数:14,代码来源:ExpectedTimeoutRuleTest.java

示例12: 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

示例13: shouldExecuteWhenUntilIsDefault

import org.junit.runner.Result; //导入方法依赖的package包/类
@Test
public void shouldExecuteWhenUntilIsDefault() {
  Result result = TestRunner.runTest(ShouldExecuteWhenUntilIsDefault.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(ShouldExecuteWhenUntilIsDefault.count).isEqualTo(1);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:IgnoreUntilRuleTest.java

示例14: failsWithOne

import org.junit.runner.Result; //导入方法依赖的package包/类
@Test
public void failsWithOne() {
  Result result = TestRunner.runTest(FailsWithOne.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(FailsWithOne.message);
  assertThat(FailsWithOne.count).isEqualTo(1);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:RetryRuleGlobalWithErrorTest.java

示例15: 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(AssertionError.class)
      .hasMessage(FailsOnSecondAttempt.message);
  assertThat(FailsOnSecondAttempt.count).isEqualTo(2);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:RetryRuleGlobalWithErrorTest.java


注:本文中的org.junit.runner.Result.getFailures方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。