当前位置: 首页>>代码示例>>Java>>正文


Java TestFailure.exceptionMessage方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:FlowControlTest.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:TimeOutHasToPrintLogTest.java

示例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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TimeOutHasToPrintLogTest.java

示例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());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:LoggingTest.java

示例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());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:LoggingTest.java

示例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());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:LoggingControlTest.java


注:本文中的junit.framework.TestFailure.exceptionMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。