X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.tests.modelled%2Fsrc%2Forg%2Fsimantics%2Ftests%2Fmodelled%2Fjunit%2FRuntimeSTSRunner.java;fp=bundles%2Forg.simantics.tests.modelled%2Fsrc%2Forg%2Fsimantics%2Ftests%2Fmodelled%2Fjunit%2FRuntimeSTSRunner.java;h=6f9bda06a2caaae035e8a8f56ac0f3bc0ec7edc3;hb=53059ca1a958697cc6235d27628614fbaa944d59;hp=0000000000000000000000000000000000000000;hpb=e87f0965679502de281692c298d66a7ae9507bd8;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/RuntimeSTSRunner.java b/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/RuntimeSTSRunner.java new file mode 100644 index 000000000..6f9bda06a --- /dev/null +++ b/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/RuntimeSTSRunner.java @@ -0,0 +1,57 @@ +package org.simantics.tests.modelled.junit; + +import java.util.List; + +import org.junit.runner.Description; +import org.junit.runner.Result; +import org.junit.runner.Runner; +import org.junit.runner.notification.Failure; +import org.junit.runner.notification.RunListener; +import org.junit.runner.notification.RunNotifier; +import org.junit.runners.ParentRunner; + +public abstract class RuntimeSTSRunner extends ParentRunner { + + public RuntimeSTSRunner(Class testClass) throws Exception { + super(testClass); + } + + public abstract void initialize() throws Exception; + + public abstract void deinitialize() throws Exception; + + @Override + protected List getChildren() { + System.out.println("getting children"); + return RuntimeTestCollector.collectTests(); + } + + @Override + protected Description describeChild(Runner child) { + return child.getDescription(); + } + + @Override + public void run(RunNotifier notifier) { + notifier.addListener(new RunListener() { + + @Override + public void testRunFinished(Result result) throws Exception { + deinitialize(); + } + }); + super.run(notifier); + } + + @Override + protected void runChild(Runner child, RunNotifier notifier) { + Description desc = describeChild(child); + notifier.fireTestStarted(desc); + try { + child.run(notifier); + notifier.fireTestFinished(desc); + } catch (Throwable e) { + notifier.fireTestFailure(new Failure(desc, e)); + } + } +}