--- /dev/null
+package org.simantics.tests.modelled.junit;\r
+\r
+import java.util.List;\r
+\r
+import org.junit.runner.Description;\r
+import org.junit.runner.Result;\r
+import org.junit.runner.Runner;\r
+import org.junit.runner.notification.Failure;\r
+import org.junit.runner.notification.RunListener;\r
+import org.junit.runner.notification.RunNotifier;\r
+import org.junit.runners.ParentRunner;\r
+\r
+public abstract class RuntimeSTSRunner extends ParentRunner<Runner> {\r
+\r
+ public RuntimeSTSRunner(Class<?> testClass) throws Exception {\r
+ super(testClass);\r
+ }\r
+\r
+ public abstract void initialize() throws Exception;\r
+\r
+ public abstract void deinitialize() throws Exception;\r
+\r
+ @Override\r
+ protected List<Runner> getChildren() {\r
+ System.out.println("getting children");\r
+ return RuntimeTestCollector.collectTests();\r
+ }\r
+\r
+ @Override\r
+ protected Description describeChild(Runner child) {\r
+ return child.getDescription();\r
+ }\r
+\r
+ @Override\r
+ public void run(RunNotifier notifier) {\r
+ notifier.addListener(new RunListener() {\r
+\r
+ @Override\r
+ public void testRunFinished(Result result) throws Exception {\r
+ deinitialize();\r
+ }\r
+ });\r
+ super.run(notifier);\r
+ }\r
+\r
+ @Override\r
+ protected void runChild(Runner child, RunNotifier notifier) {\r
+ Description desc = describeChild(child);\r
+ notifier.fireTestStarted(desc);\r
+ try {\r
+ child.run(notifier);\r
+ notifier.fireTestFinished(desc);\r
+ } catch (Throwable e) {\r
+ notifier.fireTestFailure(new Failure(desc, e));\r
+ }\r
+ }\r
+}\r