Java 类org.mockito.internal.exceptions.ExceptionIncludingMockitoWarnings 实例源码

项目:astor    文件:JUnitFailureHacker.java   
public void appendWarnings(Failure failure, String warnings) {
    if (isEmpty(warnings)) {
        return;
    }
    //TODO: this has to protect the use in case jUnit changes and this internal state logic fails
    Throwable throwable = (Throwable) Whitebox.getInternalState(failure, "fThrownException");

    String newMessage = "contains both: actual test failure *and* Mockito warnings.\n" +
            warnings + "\n *** The actual failure is because of: ***\n";

    ExceptionIncludingMockitoWarnings e = new ExceptionIncludingMockitoWarnings(newMessage, throwable);
    e.setStackTrace(throwable.getStackTrace());
    Whitebox.setInternalState(failure, "fThrownException", e);
}
项目:astor    文件:VerboseMockitoRunnerTest.java   
@Test
public void shouldContainWarnings() throws Exception {
    //when
    Result result = new JUnitCore().run(new ContainsWarnings());
    //then
    assertEquals(1, result.getFailures().size());
    Throwable exception = result.getFailures().get(0).getException();
    assertTrue(exception instanceof ExceptionIncludingMockitoWarnings);        
}
项目:astor    文件:JUnitFailureHackerTest.java   
@Test
public void shouldReplaceException() throws Exception {
    //given
    RuntimeException actualExc = new RuntimeException("foo");
    Failure failure = new Failure(Description.EMPTY, actualExc);

    //when
    hacker.appendWarnings(failure, "unused stubbing");

    //then
    assertEquals(ExceptionIncludingMockitoWarnings.class, failure.getException().getClass());
    assertEquals(actualExc, failure.getException().getCause());
    Assertions.assertThat(actualExc.getStackTrace()).isEqualTo(failure.getException().getStackTrace());
}
项目:astor    文件:JUnitFailureHacker.java   
public void appendWarnings(Failure failure, String warnings) {
    if (isEmpty(warnings)) {
        return;
    }
    //TODO: this has to protect the use in case jUnit changes and this internal state logic fails
    Throwable throwable = (Throwable) Whitebox.getInternalState(failure, "fThrownException");

    String newMessage = "contains both: actual test failure *and* Mockito warnings.\n" +
            warnings + "\n *** The actual failure is because of: ***\n";

    ExceptionIncludingMockitoWarnings e = new ExceptionIncludingMockitoWarnings(newMessage, throwable);
    e.setStackTrace(throwable.getStackTrace());
    Whitebox.setInternalState(failure, "fThrownException", e);
}
项目:astor    文件:VerboseMockitoRunnerTest.java   
@Test
@Ignore
public void shouldContainWarnings() throws Exception {
    //when
    Result result = new JUnitCore().run(new ContainsWarnings());
    //then
    assertEquals(1, result.getFailures().size());
    Throwable exception = result.getFailures().get(0).getException();
    assertTrue(exception instanceof ExceptionIncludingMockitoWarnings);        
}
项目:astor    文件:JUnitFailureHackerTest.java   
@Test
public void shouldReplaceException() throws Exception {
    //given
    RuntimeException actualExc = new RuntimeException("foo");
    Failure failure = new Failure(Description.EMPTY, actualExc);

    //when
    hacker.appendWarnings(failure, "unused stubbing");

    //then
    assertEquals(ExceptionIncludingMockitoWarnings.class, failure.getException().getClass());
    assertEquals(actualExc, failure.getException().getCause());
    Assertions.assertThat(actualExc.getStackTrace()).isEqualTo(failure.getException().getStackTrace());
}