當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。