1
16
17 import org.as2lib.app.exec.Process;
18 import org.as2lib.test.unit.TestRunner;
19 import org.as2lib.test.unit.TestCaseResult;
20 import org.as2lib.env.except.IllegalArgumentException;
21 import org.as2lib.env.log.LogSupport;
22 import org.as2lib.test.unit.TestCaseMethodInfo;
23 import org.as2lib.app.exec.ProcessStartListener;
24 import org.as2lib.app.exec.ProcessErrorListener;
25 import org.as2lib.app.exec.ProcessFinishListener;
26 import org.as2lib.app.exec.ProcessPauseListener;
27 import org.as2lib.app.exec.ProcessResumeListener;
28 import org.as2lib.app.exec.ProcessUpdateListener;
29
30
38 class org.as2lib.test.unit.LoggerTestListener extends LogSupport
39 implements ProcessStartListener,
40 ProcessErrorListener,
41 ProcessFinishListener,
42 ProcessPauseListener,
43 ProcessResumeListener,
44 ProcessUpdateListener {
45
46
47 private static var instance:LoggerTestListener;
48
49
54 public static function getInstance(Void):LoggerTestListener {
55 if (!instance) {
56 instance = new LoggerTestListener();
57 }
58 return instance;
59 }
60
61
62 private var formerTest:TestCaseResult;
63
64
67 private function LoggerTestListener() {}
68
69
70
75 public function onProcessStart(process:Process):Void {
76 logger.info("TestRunner started execution.");
77 }
78
79
84 public function onProcessUpdate(process:Process):Void {
85 var testRunner:TestRunner = TestRunner(process);
86 if (testRunner) {
87 var methodInfo:TestCaseMethodInfo = testRunner.getCurrentTestCaseMethodInfo();
88 if (methodInfo) {
89 logger.info("executing ... "+testRunner.getCurrentTestCase().getName()+"."+methodInfo.getMethodInfo().getName());
90 }
91 }
92 }
93
94
99 public function onProcessFinish(process:Process):Void {
100 var testRunner:TestRunner = TestRunner(process);
101 if(testRunner) {
102 logger.info("TestRunner finished with the result: \n"+testRunner.getTestResult().toString());
103 } else {
104 throw new IllegalArgumentException("LoggerTestListener added to a different Process", this, arguments);
105 }
106 }
107
108
113 public function onProcessPause(process:Process):Void {
114 var test:TestRunner = TestRunner(process);
115 logger.info("TestRunner paused execution at "+test.getCurrentTestCaseMethodInfo().getName());
116 }
117
118
123 public function onProcessResume(process:Process):Void {
124 var test:TestRunner = TestRunner(process);
125 logger.info("TestRunner resumed execution at "+test.getCurrentTestCaseMethodInfo().getName());
126 }
127
128
134 public function onProcessError(process:Process, error):Boolean {
135 logger.error("Exception was thrown during the execution of the TestRunner: " + error + ".");
136 return true;
137 }
138
139 }