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