From: jsimomaa Date: Thu, 29 Jun 2017 10:55:46 +0000 (+0300) Subject: Use parent name in JUnit STS test identifiers X-Git-Tag: v1.31.0~289 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=597687a4e41e9892a4b40e0de05183d930e6cc32 Use parent name in JUnit STS test identifiers Previous implementation groups all tests under ModelledSTSTestRunner.class.getName() which is not desired with modelled STS tests refs #7338 Change-Id: Iead3594ef081fa82071ccc30a9f4a33dcd3d7ceb --- diff --git a/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/v2/ModelledSTSTestRunner.java b/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/v2/ModelledSTSTestRunner.java index 06fd1a2da..204df96c3 100644 --- a/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/v2/ModelledSTSTestRunner.java +++ b/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/v2/ModelledSTSTestRunner.java @@ -21,7 +21,7 @@ public class ModelledSTSTestRunner extends Runner { @Override public Description getDescription() { if (description == null) - description = Description.createTestDescription(ModelledSTSTestRunner.class.getName(), test.getName(), new Integer(test.hashCode())); + description = Description.createTestDescription(test.getParentName(), test.getName(), new Integer(test.hashCode())); return description; } diff --git a/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/ModelledSTSTest.java b/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/ModelledSTSTest.java index c0ed9b191..94ff2b6b6 100644 --- a/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/ModelledSTSTest.java +++ b/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/ModelledSTSTest.java @@ -24,6 +24,7 @@ import org.simantics.scl.runtime.reporting.SCLReportingHandler; public class ModelledSTSTest { private final String name; + private final String parentName; private final String code; private final int priority; private final boolean ignored; @@ -33,8 +34,9 @@ public class ModelledSTSTest { private CombinedCoverage coverage; private Map variables; - ModelledSTSTest(String name, String code, int priority, boolean ignored, Set dependencies, Map variables) { + ModelledSTSTest(String name, String parentName, String code, int priority, boolean ignored, Set dependencies, Map variables) { this.name = name; + this.parentName = parentName; this.code = code; this.priority = priority; this.ignored = ignored; @@ -47,6 +49,10 @@ public class ModelledSTSTest { return name; } + public String getParentName() { + return parentName; + } + public String getCode() { return code; } diff --git a/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/STSSuiteTestCollector.java b/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/STSSuiteTestCollector.java index 58aa323e1..56d43aec9 100644 --- a/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/STSSuiteTestCollector.java +++ b/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/STSSuiteTestCollector.java @@ -95,7 +95,14 @@ public class STSSuiteTestCollector { String value = graph.getRelatedValue(stsVariable, TESTS.STSVariable_definition); variables.put(name, value); } - return new ModelledSTSTest(testName, code, priority != null ? priority : -1, ignored != null ? ignored : false, new HashSet<>(Arrays.asList(actualDeps)), variables); + Resource parent = graph.getSingleObject(test, L0.PartOf); + String parentName; + String possibleURI = graph.getPossibleURI(parent); + if (possibleURI != null) + parentName = possibleURI; + else + parentName = graph.getRelatedValue2(parent, L0.HasName, Bindings.STRING); + return new ModelledSTSTest(testName, parentName, code, priority != null ? priority : -1, ignored != null ? ignored : false, new HashSet<>(Arrays.asList(actualDeps)), variables); } public static ModelledSTSSuite toModelledSuite(ReadGraph graph, Resource suite, List children) throws DatabaseException {