本文整理匯總了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);
}
示例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();
}
示例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...");
}
}
示例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);
}
示例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);
}
示例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 + "\")");
}
示例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();
}
示例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);
}
示例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());
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}