项目: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);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。