1 package org.junit.runner; 2 3 import java.util.ArrayList ; 4 import java.util.List ; 5 6 import org.junit.runner.notification.Failure; 7 import org.junit.runner.notification.RunListener; 8 9 14 public class Result { 15 private int fCount= 0; 16 private int fIgnoreCount= 0; 17 private List <Failure> fFailures= new ArrayList <Failure>(); 18 private long fRunTime= 0; 19 private long fStartTime; 20 21 24 public int getRunCount() { 25 return fCount; 26 } 27 28 31 public int getFailureCount() { 32 return fFailures.size(); 33 } 34 35 38 public long getRunTime() { 39 return fRunTime; 40 } 41 42 45 public List <Failure> getFailures() { 46 return fFailures; 47 } 48 49 52 public int getIgnoreCount() { 53 return fIgnoreCount; 54 } 55 56 59 public boolean wasSuccessful() { 60 return getFailureCount() == 0; 61 } 62 63 private class Listener extends RunListener { 64 @Override 65 public void testRunStarted(Description description) throws Exception { 66 fStartTime= System.currentTimeMillis(); 67 } 68 69 @Override 70 public void testRunFinished(Result result) throws Exception { 71 long endTime= System.currentTimeMillis(); 72 fRunTime+= endTime - fStartTime; 73 } 74 75 @Override 76 public void testStarted(Description description) throws Exception { 77 fCount++; 78 } 79 80 @Override 81 public void testFailure(Failure failure) throws Exception { 82 fFailures.add(failure); 83 } 84 85 @Override 86 public void testIgnored(Description description) throws Exception { 87 fIgnoreCount++; 88 } 89 } 90 91 94 public RunListener createListener() { 95 return new Listener(); 96 } 97 } 98 | Popular Tags |