本文整理汇总了Java中junit.framework.TestFailure.exceptionMessage方法的典型用法代码示例。如果您正苦于以下问题:Java TestFailure.exceptionMessage方法的具体用法?Java TestFailure.exceptionMessage怎么用?Java TestFailure.exceptionMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类junit.framework.TestFailure
的用法示例。
在下文中一共展示了TestFailure.exceptionMessage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRuntimeExceptionsAlsoGenerateLog
import junit.framework.TestFailure; //导入方法依赖的package包/类
public void testRuntimeExceptionsAlsoGenerateLog() throws Exception {
if (throwIt != null) {
Logger.getLogger("").info("Ahoj");
throw throwIt;
}
FlowControlTest l = new FlowControlTest("testRuntimeExceptionsAlsoGenerateLog");
l.throwIt = new NullPointerException();
TestResult res = l.run();
assertEquals("No failures", 0, res.failureCount());
assertEquals("One error", 1, res.errorCount());
Object o = res.errors().nextElement();
TestFailure f = (TestFailure)o;
if (f.exceptionMessage() == null || f.exceptionMessage().indexOf("Ahoj") == -1) {
fail("Logged messages shall be in exception message: " + f.exceptionMessage());
}
}
示例2: testThatTheTimeOutStillPrintsTheWarning
import junit.framework.TestFailure; //导入方法依赖的package包/类
public void testThatTheTimeOutStillPrintsTheWarning() throws Exception {
TimeOutHasToPrintLogTest t = new TimeOutHasToPrintLogTest("printAhojAndTimeOut");
CharSequence seq = Log.enable(LOG.getName(), Level.FINE);
TestResult res = t.run();
assertEquals("One test has been run", 1, res.runCount());
String s = seq.toString();
if (s.indexOf("Ahoj") == -1) {
fail("Ahoj has to be logged:\n" + s);
}
assertEquals("No error", 0, res.errorCount());
assertEquals("One failure", 1, res.failureCount());
TestFailure f = (TestFailure)res.failures().nextElement();
s = f.exceptionMessage();
if (s.indexOf("Ahoj") == -1) {
fail("Ahoj has to be part of the message:\n" + s);
}
}
示例3: testThreadDumpPrinted
import junit.framework.TestFailure; //导入方法依赖的package包/类
public void testThreadDumpPrinted() throws Exception {
TimeOutHasToPrintLogTest t = new TimeOutHasToPrintLogTest("justTimeOutInOneOfMyMethods");
TestResult res = t.run();
assertEquals("One test has been run", 1, res.runCount());
TestFailure failure = (TestFailure)res.failures().nextElement();
String s = failure.exceptionMessage();
if (s.indexOf("justTimeOutInOneOfMyMethods") == -1) {
fail("There should be thread dump reported in case of timeout:\n" + s);
}
assertEquals("No error", 0, res.errorCount());
assertEquals("One failure", 1, res.failureCount());
}
示例4: testMyExceptionIsWrappedWithLogMsg
import junit.framework.TestFailure; //导入方法依赖的package包/类
public void testMyExceptionIsWrappedWithLogMsg() throws Exception {
LoggingTest inner = new LoggingTest("throwMyThrowable");
class MyEx extends Exception {
}
inner.toThrow = new MyEx();
TestResult res = inner.run();
assertEquals("One error", 1, res.errorCount());
assertEquals("No failure", 0, res.failureCount());
TestFailure f = (TestFailure)res.errors().nextElement();
if (f.exceptionMessage() == null || f.exceptionMessage().indexOf("Going to throw") == -1) {
fail("There should be output of the log:\n" + f.exceptionMessage());
}
}
示例5: testMyExceptionWithStackTrace
import junit.framework.TestFailure; //导入方法依赖的package包/类
public void testMyExceptionWithStackTrace() throws Exception {
LoggingTest inner = new LoggingTest("throwMyThrowable");
class MyEx extends Exception {
}
inner.toThrow = new MyEx();
inner.toMsg = new MyEx();
TestResult res = inner.run();
assertEquals("One error", 1, res.errorCount());
assertEquals("No failure", 0, res.failureCount());
TestFailure f = (TestFailure)res.errors().nextElement();
if (
f.exceptionMessage() == null ||
f.exceptionMessage().indexOf("Going to throw") == -1 ||
f.exceptionMessage().indexOf("testMyExceptionWithStackTrace") == -1
) {
fail("There should be output of the log:\n" + f.exceptionMessage());
}
}
示例6: testRuntimeExceptionsAlsoGenerateLog
import junit.framework.TestFailure; //导入方法依赖的package包/类
public void testRuntimeExceptionsAlsoGenerateLog() throws Exception {
if (throwIt != null) {
Logger.getLogger("global").info("Ahoj");
throw throwIt;
}
LoggingControlTest l = new LoggingControlTest("testRuntimeExceptionsAlsoGenerateLog");
l.throwIt = new NullPointerException();
TestResult res = l.run();
assertEquals("No failures", 0, res.failureCount());
assertEquals("One error", 1, res.errorCount());
Object o = res.errors().nextElement();
TestFailure f = (TestFailure)o;
if (f.exceptionMessage() == null || f.exceptionMessage().indexOf("Ahoj") == -1) {
fail("Logged messages shall be in exception message: " + f.exceptionMessage());
}
}