本文整理汇总了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);
}