1 package org.simantics.tests.modelled.junit.v2;
4 import java.util.stream.Collectors;
6 import org.eclipse.core.runtime.NullProgressMonitor;
7 import org.junit.runner.Description;
8 import org.junit.runner.Result;
9 import org.junit.runner.notification.RunListener;
10 import org.junit.runner.notification.RunNotifier;
11 import org.junit.runners.ParentRunner;
12 import org.junit.runners.model.InitializationError;
13 import org.simantics.Simantics;
14 import org.simantics.db.testing.common.AcornTests;
15 import org.simantics.scl.compiler.commands.CommandSession;
16 import org.simantics.scl.osgi.SCLOsgi;
17 import org.simantics.tests.modelled.utils.STSSuiteTestCollector;
19 public class ModelledSTSRunner extends ParentRunner<ModelledSTSSuiteRunner> {
21 private CommandSession commandSession;
23 public ModelledSTSRunner(Class<?> testClass) throws Exception {
29 protected List<ModelledSTSSuiteRunner> getChildren() {
30 return STSSuiteTestCollector.collectTests().stream().map(suite -> {
32 return new ModelledSTSSuiteRunner(suite);
33 } catch (Exception e) {
34 throw new RuntimeException(e);
36 }).collect(Collectors.toList());
40 protected Description describeChild(ModelledSTSSuiteRunner child) {
41 return child.getDescription();
45 public void run(RunNotifier notifier) {
46 notifier.addListener(new RunListener() {
49 public void testRunFinished(Result result) throws Exception {
57 protected void runChild(ModelledSTSSuiteRunner child, RunNotifier notifier) {
58 child.setCommandSesssion(commandSession);
60 // TODO: Add coverage reporting to ModelledSTSRunner
61 // CombinedCoverage cover = child.getCoverage();
62 // CoverageBuilder b = new CoverageBuilder();
65 public void initialize() throws InitializationError {
68 public void deinitialize() throws Exception {
71 private void initialize0() throws Exception {
72 AcornTests.newSimanticsWorkspace(null, null);
73 this.commandSession = new CommandSession(SCLOsgi.MODULE_REPOSITORY, null);
77 private void deinitialize0() throws Exception {
79 Simantics.shutdown(new NullProgressMonitor());