1 54 55 package junitx.runner.listener; 56 57 import java.awt.Toolkit ; 58 import java.util.Properties ; 59 60 import junit.framework.Test; 61 import junit.framework.TestResult; 62 63 79 public class BeeperListener extends AbstractRunListener { 80 81 84 private boolean runStarted = false; 85 86 89 private boolean runEnded = false; 90 91 94 private boolean testStarted = false; 95 96 99 private boolean testSuccess = false; 100 101 104 private boolean testFailure = true; 105 106 109 private boolean testError = true; 110 111 public void init(Properties props) throws Exception { 112 super.init(props); 113 114 this.runStarted = Boolean.valueOf(props.getProperty("BeeperListener.run_started", "false")).booleanValue(); 115 this.runEnded = Boolean.valueOf(props.getProperty("BeeperListener.run_ended", "false")).booleanValue(); 116 this.testStarted = Boolean.valueOf(props.getProperty("BeeperListener.test_started", "false")).booleanValue(); 117 this.testSuccess = Boolean.valueOf(props.getProperty("BeeperListener.test_success", "false")).booleanValue(); 118 this.testFailure = Boolean.valueOf(props.getProperty("BeeperListener.test_failure", "true")).booleanValue(); 119 this.testError = Boolean.valueOf(props.getProperty("BeeperListener.test_error", "true")).booleanValue(); 120 } 121 122 public void runStarted(Test test, long time) { 123 if (this.runStarted) { 124 Toolkit.getDefaultToolkit().beep(); 125 } 126 } 127 128 public void runStopped(Test test, long duration) { 129 } 130 131 public void runEnded(Test test, TestResult result, long duration) { 132 if (this.runEnded) { 133 Toolkit.getDefaultToolkit().beep(); 134 } 135 } 136 137 public void testIgnored(Test test) { 138 } 139 140 public void testStarted(Test test, TestResult result) { 141 if (this.testStarted) { 142 Toolkit.getDefaultToolkit().beep(); 143 } 144 } 145 146 public void testFailure(Test test, TestResult result, Throwable t) { 147 if (testFailure) { 148 Toolkit.getDefaultToolkit().beep(); 149 } 150 } 151 152 public void testError(Test test, TestResult result, Throwable t) { 153 if (testError) { 154 Toolkit.getDefaultToolkit().beep(); 155 } 156 } 157 158 public void testSuccess(Test test, TestResult result) { 159 if (this.testSuccess) { 160 Toolkit.getDefaultToolkit().beep(); 161 } 162 } 163 164 165 166 } 167 | Popular Tags |