1 16 17 package org.springframework.test; 18 19 import junit.framework.TestCase; 20 import org.apache.commons.logging.Log; 21 import org.apache.commons.logging.LogFactory; 22 23 37 public abstract class ConditionalTestCase extends TestCase { 38 39 private static int disabledTestCount; 40 41 42 protected final Log logger = LogFactory.getLog(getClass()); 43 44 45 48 public ConditionalTestCase() { 49 } 50 51 54 public ConditionalTestCase(String name) { 55 super(name); 56 } 57 58 59 public void runBare() throws Throwable { 60 if (isDisabledInThisEnvironment(getName())) { 62 recordDisabled(); 63 logger.info("**** " + getClass().getName() + "." + getName() + " disabled in this environment: " + 64 "Total disabled tests=" + getDisabledTestCount()); 65 return; 66 } 67 68 super.runBare(); 70 } 71 72 77 protected boolean isDisabledInThisEnvironment(String testMethodName) { 78 return false; 79 } 80 81 85 protected int recordDisabled() { 86 return ++disabledTestCount; 87 } 88 89 90 93 public static int getDisabledTestCount() { 94 return disabledTestCount; 95 } 96 97 } 98 | Popular Tags |