]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/RuntimeSTSRunner.java
Merge changes Ib64cf026,I238948da
[simantics/platform.git] / bundles / org.simantics.tests.modelled / src / org / simantics / tests / modelled / junit / RuntimeSTSRunner.java
1 package org.simantics.tests.modelled.junit;
2
3 import org.junit.runner.Description;
4 import org.junit.runner.Result;
5 import org.junit.runner.Runner;
6 import org.junit.runner.notification.Failure;
7 import org.junit.runner.notification.RunListener;
8 import org.junit.runner.notification.RunNotifier;
9 import org.junit.runners.ParentRunner;
10
11 @Deprecated
12 public abstract class RuntimeSTSRunner<T extends Runner> extends ParentRunner<T> {
13
14     public RuntimeSTSRunner(Class<?> testClass) throws Exception {
15         super(testClass);
16     }
17
18     public abstract void initialize() throws Exception;
19
20     public abstract void deinitialize() throws Exception;
21
22     @Override
23     protected Description describeChild(Runner child) {
24         return child.getDescription();
25     }
26
27     @Override
28     public void run(RunNotifier notifier) {
29         notifier.addListener(new RunListener() {
30
31             @Override
32             public void testRunFinished(Result result) throws Exception {
33                 deinitialize();
34             }
35         });
36         super.run(notifier);
37     }
38
39     @Override
40     protected void runChild(Runner child, RunNotifier notifier) {
41         Description desc = describeChild(child);
42         notifier.fireTestStarted(desc);
43         try {
44             child.run(notifier);
45             notifier.fireTestFinished(desc);
46         } catch (Throwable e) {
47             notifier.fireTestFailure(new Failure(desc, e));
48         }
49     }
50 }