Clover coverage report - DrJava Test Coverage (drjava-20120304-r5456)
Coverage timestamp: Sun Mar 4 2012 03:13:23 CST
file stats: LOC: 113   Methods: 8
NCLOC: 35   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
JUnitError.java - 38.9% 37.5% 38.5%
coverage coverage
 1    /*BEGIN_COPYRIGHT_BLOCK
 2    *
 3    * Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu)
 4    * All rights reserved.
 5    *
 6    * Redistribution and use in source and binary forms, with or without
 7    * modification, are permitted provided that the following conditions are met:
 8    * * Redistributions of source code must retain the above copyright
 9    * notice, this list of conditions and the following disclaimer.
 10    * * Redistributions in binary form must reproduce the above copyright
 11    * notice, this list of conditions and the following disclaimer in the
 12    * documentation and/or other materials provided with the distribution.
 13    * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
 14    * names of its contributors may be used to endorse or promote products
 15    * derived from this software without specific prior written permission.
 16    *
 17    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 18    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 19    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 20    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 21    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 22    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 23    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 24    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 25    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 26    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 27    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28    *
 29    * This software is Open Source Initiative approved Open Source Software.
 30    * Open Source Initative Approved is a trademark of the Open Source Initiative.
 31    *
 32    * This file is part of DrJava. Download the current version of this project
 33    * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
 34    *
 35    * END_COPYRIGHT_BLOCK*/
 36   
 37    package edu.rice.cs.drjava.model.junit;
 38   
 39    import edu.rice.cs.drjava.model.DJError;
 40   
 41    import java.io.File;
 42    import java.io.Serializable;
 43   
 44    /** A class to represent JUnit errors. This class enables DrJava to highlight the exact error text.
 45    * @version $Id: JUnitError.java 5439 2011-08-11 17:13:04Z rcartwright $
 46    */
 47    public class JUnitError extends DJError implements Serializable {
 48    private volatile String _test;
 49    private volatile String _className;
 50    private volatile String _exception;
 51    private volatile StackTraceElement[] _stackTrace;
 52   
 53    /** Constructor.
 54    * @param file the file where the error occurred
 55    * @param lineNumber the line number of the error
 56    * @param startColumn the starting column of the error
 57    * @param message the error message
 58    * @param isWarning true if the error is a warning
 59    * @param test the name of the test that failed
 60    */
 61  13 public JUnitError(File file, int lineNumber, int startColumn, String message, boolean isWarning, String test,
 62    String className, String exception, StackTraceElement[] stackTrace) {
 63  13 super(file, lineNumber, startColumn, message, isWarning);
 64  13 _test = test;
 65  13 _className = className;
 66  13 _exception = exception;
 67  13 _stackTrace = stackTrace;
 68    }
 69   
 70    /** Constructor for an error with no associated location. This constructor also
 71    * provides a default stackTrace.
 72    * @param message the error message
 73    * @param isWarning true if the error is a warning
 74    * @param test the name of the test that failed
 75    */
 76  0 public JUnitError(String message, boolean isWarning, String test) {
 77  0 this(null, -1, -1, message, isWarning, test, "", "No associated stack trace", new StackTraceElement[0]);
 78    }
 79   
 80    /** Gets the test name
 81    * @return the test name
 82    */
 83  0 public String testName() { return _test; }
 84   
 85    /** Gets the class name
 86    * @return the class name
 87    */
 88  0 public String className() { return _className; }
 89   
 90    /** All JUnit errors are Throwables that have been thrown, so all have
 91    * a stack trace
 92    * @return the stack trace associated with the error
 93    */
 94  0 public String exception() { return _exception; }
 95   
 96    /** Return the array of stack trace elements. */
 97  13 public StackTraceElement[] stackTrace() { return _stackTrace; }
 98   
 99    /** Set the array of stack trace elements. */
 100  13 public void setStackTrace(StackTraceElement[] stes) { _stackTrace = stes; }
 101   
 102  0 public String toString() {
 103  0 StringBuilder sb = new StringBuilder();
 104  0 sb.append(_exception);
 105   
 106  0 for(StackTraceElement s: _stackTrace) {
 107  0 sb.append('\n');
 108  0 sb.append("\tat ");
 109  0 sb.append(s);
 110    }
 111  0 return sb.toString();
 112    }
 113    }