Package org.junit.runner.notification

Examples of org.junit.runner.notification.Failure


    @Test
    public void canUnadaptAnAdapter() {
        JUnit38ClassRunner runner = new JUnit38ClassRunner(new JUnit4TestAdapter(AnnotatedTest.class));
        Result result = new JUnitCore().run(runner);
        Failure failure = result.getFailures().get(0);
        assertEquals(Description.createTestDescription(AnnotatedTest.class, "foo"), failure.getDescription());
    }
View Full Code Here


    }

    @Test
    public void invalidTestMethodReportedCorrectly() {
        Result result = JUnitCore.runClasses(ClassWithInvalidMethod.class);
        Failure failure = result.getFailures().get(0);
        assertEquals("warning", failure.getDescription().getMethodName());
        assertEquals("junit.framework.TestSuite$1", failure.getDescription().getClassName());
    }
View Full Code Here

        assumeThat(value, not(matcher2));
        assertThat(matcher1.toString(), not(matcher2.toString()));
    }

    private static Failure failure(String string) {
        return new Failure(Description.EMPTY, new Error(string));
    }
View Full Code Here

        assertEquals("ignoreCount", result.getIgnoreCount(), fromStream.getIgnoreCount());
        assertEquals("runTime", result.getRunTime(), fromStream.getRunTime());
        assertEquals("failures", result.getFailures().size(), fromStream.getFailures().size());
        int index = 0;
        for (Failure failure : result.getFailures()) {
            Failure failureFromStream = fromStream.getFailures().get(index);
            String messagePrefix = String.format("failures[%d]", index++);
            assertEquals(messagePrefix + ".description",
                    failure.getDescription(), failureFromStream.getDescription());
            Throwable exception = failure.getException();
            Throwable exceptionFromStream = failureFromStream.getException();
            assertEquals(messagePrefix + ".exception",
                    exception.getClass(), exceptionFromStream.getClass());
            assertEquals(messagePrefix + ".exception",
                    exception.getMessage(), exceptionFromStream.getMessage());
        }
View Full Code Here

    }

    @Test
    public void unexpected() {
        Result result = JUnitCore.runClasses(Unexpected.class);
        Failure failure = result.getFailures().get(0);
        String message = failure.getMessage();
        assertTrue(message.contains("expected<java.lang.Exception> but was<java.lang.Error>"));
        assertEquals(Error.class, failure.getException().getCause().getClass());
    }
View Full Code Here

            Description childDescription = describeChild(child);
            notifier.fireTestStarted(childDescription);
            SpecificationReport report = child.playbackBehaviour();
            reportResults(notifier, report, childDescription);
        } catch (final Exception e) {
            notifier.fireTestFailure(new Failure(getDescription(), e));
            log.error(e.getMessage(), e);
        }
    }
View Full Code Here

        switch (spec.getResult()) {
            case SUCCESS:
                notifier.fireTestFinished(test);
                return;
            case FAILURE:
                notifier.fireTestFailure(new Failure(test, new TestFailure(spec.getMessage())));
                return;
            case ERROR:
            default:
                throw new SpecificationError(spec.getMessage(), spec.getCause());
        }
View Full Code Here

  }

  private void setUpUsing(String methodName) throws Exception {
    testInfo = new TestInfo(new Object(), testClass, method(methodName));
    runner = new MethodRunner(testInfo, notifier, screenshotTaker);
    expectedFailure = new Failure(testInfo.description(), exception);
  }
View Full Code Here

      buffer.append("exception=").append(expected.getException().getMessage()).append("]");
    }

    public boolean matches(Object argument) {
      if (!(argument instanceof Failure)) return false;
      Failure actual = (Failure) argument;
      if (!areEqual(expected.getDescription(), actual.getDescription())) return false;
      return areEqual(expected.getException(), actual.getException());
    }
View Full Code Here

  private Failure failure;

  @Override void onSetUp() {
    description = createSuiteDescription("Hello");
    cause = new Exception();
    failure = new Failure(description, cause);
  }
View Full Code Here

TOP

Related Classes of org.junit.runner.notification.Failure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.