1 28 29 package com.idaremedia.antx.ut; 30 31 import junit.framework.AssertionFailedError; 32 import junit.framework.Test; 33 import junit.framework.TestResult; 34 35 46 47 public class HAbortingResult extends TestResult 48 { 49 52 public HAbortingResult() 53 { 54 super(); 55 } 56 57 58 63 public HAbortingResult(int maxFailures, int maxErrors) 64 { 65 super(); 66 m_maxFailures= maxFailures; 67 m_maxErrors= maxErrors; 68 } 69 70 71 72 82 public void setStartPoints(int failure0th, int error0th) 83 { 84 m_0thFailure = failure0th; m_0thError = error0th; 86 } 87 88 89 90 97 public final void newStartPoints() 98 { 99 setStartPoints(fFailures.size(),fErrors.size()); 100 } 101 102 103 104 109 public final void popStartPoints() 110 { 111 setStartPoints(0,0); } 113 114 115 116 120 public synchronized void addError(Test test, Throwable t) 121 { 122 super.addError(test,t); 123 if (fErrors.size()-get0thError()>=m_maxErrors) { 124 this.stop(); 125 } 126 } 127 128 129 133 public synchronized void addFailure(Test test, AssertionFailedError t) 134 { 135 super.addFailure(test,t); 136 if (fFailures.size()-get0thFailure()>=m_maxFailures) { 137 this.stop(); 138 } 139 } 140 141 142 147 public int getMaximumFailures() 148 { 149 return m_maxFailures; 150 } 151 152 153 157 public void setMaximumFailures(int maxFailures) 158 { 159 m_maxFailures = maxFailures; 160 } 161 162 163 168 public int getMaximumErrors() 169 { 170 return m_maxErrors; 171 } 172 173 174 178 public void setMaximumErrors(int maxErrors) 179 { 180 m_maxErrors = maxErrors; 181 } 182 183 184 188 public final boolean isFailQuick() 189 { 190 return getMaximumErrors()==1 && getMaximumFailures()==1; 191 } 192 193 194 198 public final void setFailQuick() 199 { 200 setMaximumErrors(1); 201 setMaximumFailures(1); 202 } 203 204 205 206 private int get0thError() 207 { 208 return m_0thError; } 210 211 private int get0thFailure() 212 { 213 return m_0thFailure; } 215 216 217 protected int m_maxFailures= Integer.MAX_VALUE; 218 protected int m_maxErrors= Integer.MAX_VALUE; 219 protected int m_0thError= 0; 220 protected int m_0thFailure= 0; 221 } 222 223 224 225 | Popular Tags |