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    文件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);        
}

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...