Use parent name in JUnit STS test identifiers 63/663/2
authorjsimomaa <jani.simomaa@gmail.com>
Thu, 29 Jun 2017 10:55:46 +0000 (13:55 +0300)
committerJani Simomaa <jani.simomaa@semantum.fi>
Thu, 29 Jun 2017 11:19:34 +0000 (14:19 +0300)
Previous implementation groups all tests under
ModelledSTSTestRunner.class.getName() which is not desired with modelled
STS tests

refs #7338

Change-Id: Iead3594ef081fa82071ccc30a9f4a33dcd3d7ceb

bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/v2/ModelledSTSTestRunner.java
bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/ModelledSTSTest.java
bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/STSSuiteTestCollector.java

index 06fd1a2da0eb3e6331c3af44606f0f97643284f0..204df96c3f968bdf5f5f1b9dde9a85bc39310f6b 100644 (file)
@@ -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;
     }
 
index c0ed9b191420604d49cfc73edd636d9f00928920..94ff2b6b6a4082a78dc5f006b0038d0b22999637 100644 (file)
@@ -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<String, String> variables;
 
-    ModelledSTSTest(String name, String code, int priority, boolean ignored, Set<String> dependencies, Map<String, String> variables) {
+    ModelledSTSTest(String name, String parentName, String code, int priority, boolean ignored, Set<String> dependencies, Map<String, String> 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;
     }
index 58aa323e1e98e5053380b1579eaf2c27823f4e85..56d43aec9ad47db272aea9905636ee30e9b20355 100644 (file)
@@ -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<ModelledSTSTest> children) throws DatabaseException {