It's all about the answers!

Ask a question

How to get only the last test result and not all the results of a Test Execution.


Oded Mozesh (52818) | asked Jun 05 '19, 7:42 a.m.
edited Jun 05 '19, 9:18 a.m. by Martin Madzio (9617)

 I have the following JRS query, and I get all the runs results of a Test and not the last one.


I tried to get only the max of test result end time, but I failed to understand how can I filter the results such I get only tthe records where the max(end time) = end time


The results I get are:
Manage Faults2058Aviary Connection Test153573The Aviary SoS consists of the UAV aircraft (Hummingbird), Pilot Controller (Bird Cage) and up to four separate Viewers (Bird Watcher).Aviary Connection TestFailed
Aviary Connection TestInconclusive
Aviary Connection TestPassed
Manually Directed Flight2058Aviary Connection Test153573The Aviary SoS consists of the UAV aircraft (Hummingbird), Pilot Controller (Bird Cage) and up to four separate Viewers (Bird Watcher).Aviary Connection TestFailed
Aviary Connection TestInconclusive
Aviary Connection TestPassed

But there should be only one result for Test Result (and not 3)

Following is the used query

PREFIX process: <http://jazz.net/ns/process#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT DISTINCT
  ?rqm_merged_QMTestPlan1_title
  ?rqm_merged_QMTestCase1_shortId
  ?rqm_merged_QMTestCase1_title
  ?dng_merged_SystemRequirement1_identifier
  ?dng_merged_SystemRequirement1_title
  ?rqm_merged_QMTestResult1_title
  ?rqm_merged_QMTestResult1_verdict
WHERE{
  ?rqm_merged_QMTestPlan1_uri process:projectArea ?rqm_merged_QMTestPlan1_paUri.
  FILTER(?rqm_merged_QMTestPlan1_paUri IN (<https://demmy.com/gc/process/project-areas/_1FLV0DbAEemg-MTlSloFXg>,
            <https://demmy.com/rm/process/project-areas/_QhSGcCMJEem4vZIQTRKFzA>,
            <https://demmy.com/qm/process/project-areas/_zVcYACMAEemxqL7t80wk5Q>))
  ?rqm_merged_QMTestPlan1_uri oslc_qm:usesTestCase ?rqm_merged_QMTestCase1_uri.
  ?rqm_merged_QMTestPlan1_uri oslc:instanceShape ?rqm_merged_QMTestPlan1_uri_instanceShape.
  ?rqm_merged_QMTestPlan1_uri_instanceShape merge:mergeShape rqm_merged:QM%20Test%20Plan.
  ?rqm_merged_QMTestPlan1_uri dcterms:title ?rqm_merged_QMTestPlan1_title.
  OPTIONAL {?rqm_merged_QMTestPlan1_ver dcterms:isVersionOf ?rqm_merged_QMTestPlan1_uri; rdf:type oslc_config:VersionResource.}
  ?rqm_merged_QMTestCase1_uri process:projectArea ?rqm_merged_QMTestCase1_paUri.
  FILTER(?rqm_merged_QMTestCase1_paUri IN (<https://demmy.com/gc/process/project-areas/_1FLV0DbAEemg-MTlSloFXg>,
            <https://demmy.com/rm/process/project-areas/_QhSGcCMJEem4vZIQTRKFzA>,
            <https://demmy.com/qm/process/project-areas/_zVcYACMAEemxqL7t80wk5Q>))
  {
    ?rqm_merged_QMTestCase1_uri oslc_qm:validatesRequirement ?dng_merged_SystemRequirement1_uri.
  } UNION {
    ?dng_merged_SystemRequirement1_uri oslc_rm:validatedBy ?rqm_merged_QMTestCase1_uri.
  }
  ?rqm_merged_QMTestResult1_uri oslc_qm:reportsOnTestCase ?rqm_merged_QMTestCase1_uri.
  ?rqm_merged_QMTestCase1_uri oslc:instanceShape ?rqm_merged_QMTestCase1_uri_instanceShape.
  ?rqm_merged_QMTestCase1_uri_instanceShape merge:mergeShape rqm_merged:QM%20Test%20Case.
  ?rqm_merged_QMTestCase1_uri dcterms:title ?rqm_merged_QMTestCase1_title.
  OPTIONAL {
    ?rqm_merged_QMTestCase1_uri oslc:shortId ?rqm_merged_QMTestCase1_shortId.
  }
  OPTIONAL {?rqm_merged_QMTestCase1_ver dcterms:isVersionOf ?rqm_merged_QMTestCase1_uri; rdf:type oslc_config:VersionResource.}
  ?rqm_merged_QMTestResult1_uri process:projectArea ?rqm_merged_QMTestResult1_paUri.
  FILTER(?rqm_merged_QMTestResult1_paUri IN (<https://demmy.com/gc/process/project-areas/_1FLV0DbAEemg-MTlSloFXg>,
            <https://demmy.com/rm/process/project-areas/_QhSGcCMJEem4vZIQTRKFzA>,
            <https://demmy.com/qm/process/project-areas/_zVcYACMAEemxqL7t80wk5Q>))
  ?rqm_merged_QMTestResult1_uri oslc:instanceShape ?rqm_merged_QMTestResult1_uri_instanceShape.
  ?rqm_merged_QMTestResult1_uri_instanceShape merge:mergeShape rqm_merged:QM%20Test%20Result.
  ?rqm_merged_QMTestResult1_uri dcterms:title ?rqm_merged_QMTestResult1_title.
  OPTIONAL {
    ?rqm_merged_QMTestResult1_uri rqm:verdict ?rqm_merged_QMTestResult1_verdict_enumValue.
    OPTIONAL {{?rqm_merged_QMTestResult1_verdict_enumValue rdfs:label ?rqm_merged_QMTestResult1_verdict_enumName} UNION {?rqm_merged_QMTestResult1_verdict_enumValue dcterms:title ?rqm_merged_QMTestResult1_verdict_enumName}}
  }
  OPTIONAL {?rqm_merged_QMTestResult1_ver dcterms:isVersionOf ?rqm_merged_QMTestResult1_uri; rdf:type oslc_config:VersionResource.}
  BIND( IF (bound(?rqm_merged_QMTestPlan1_ver), concat(str(?rqm_merged_QMTestPlan1_uri), "?oslc_config.context="), ?rqm_merged_QMTestPlan1_uri) as ?rqm_merged_QMTestPlan1)
  BIND( IF (bound(?rqm_merged_QMTestCase1_ver), concat(str(?rqm_merged_QMTestCase1_uri), "?oslc_config.context="), ?rqm_merged_QMTestCase1_uri) as ?rqm_merged_QMTestCase1)
  BIND( IF (bound(?rqm_merged_QMTestResult1_ver), concat(str(?rqm_merged_QMTestResult1_uri), "?oslc_config.context="), ?rqm_merged_QMTestResult1_uri) as ?rqm_merged_QMTestResult1)
  BIND( IF(bound(?rqm_merged_QMTestResult1_verdict_enumName), ?rqm_merged_QMTestResult1_verdict_enumName, IF(bound(?rqm_merged_QMTestResult1_verdict_enumValue), ?rqm_merged_QMTestResult1_verdict_enumValue, "")) as ?rqm_merged_QMTestResult1_verdict)
  ?dng_merged_SystemRequirement1_uri process:projectArea ?dng_merged_SystemRequirement1_paUri.
  FILTER(?dng_merged_SystemRequirement1_paUri=<https://demmy.com/rm/process/project-areas/_QhSGcCMJEem4vZIQTRKFzA>)
  ?dng_merged_SystemRequirement1_uri oslc:instanceShape ?dng_merged_SystemRequirement1_uri_instanceShape.
  ?dng_merged_SystemRequirement1_uri_instanceShape merge:mergeShape dng_merged:System%20Requirement.
  ?dng_merged_SystemRequirement1_uri dcterms:title ?dng_merged_SystemRequirement1_title.
  OPTIONAL {
    ?dng_merged_SystemRequirement1_uri dcterms:identifier ?dng_merged_SystemRequirement1_identifier.
  }
  OPTIONAL {?dng_merged_SystemRequirement1_ver dcterms:isVersionOf ?dng_merged_SystemRequirement1_uri; rdf:type oslc_config:VersionResource.}
  BIND( IF (bound(?dng_merged_SystemRequirement1_ver), concat(str(?dng_merged_SystemRequirement1_uri), "?oslc_config.context="), ?dng_merged_SystemRequirement1_uri) as ?dng_merged_SystemRequirement1)
}
ORDER BY asc(?rqm_merged_QMTestPlan1_title) asc(?rqm_merged_QMTestCase1_shortId) asc(?rqm_merged_QMTestCase1_title) asc(?dng_merged_SystemRequirement1_identifier) asc(?dng_merged_SystemRequirement1_title)

Accepted answer


permanent link
Kathryn Fryer (503147) | answered Jun 05 '19, 9:40 a.m.
The Test Execution Record has a relationship to "Current Test Result" (rqm:currentTestResult). Use that relationship to get the most recent result.
Oded Mozesh selected this answer as the correct answer

Comments
Oded Mozesh commented Jun 09 '19, 12:59 a.m. | edited Jun 09 '19, 1:01 a.m.

 
In the report builder instead of getting directly the test case results, I got the execution record and then the current test result.


Bellow if the relations chain I used:

Trace relationships and add artifacts

QM Test Plan-> Rel:Uses Test Case ->QM Test Case-> Rel:Run By ->QM Test Execution record-> Rel:Current Test Case Result ->QM Test Result


Kathryn Fryer commented Jun 10 '19, 9:51 a.m.
There is a potential issue with that path: once you get to the Test Case, it could have Execution Records that are unrelated to the original Test Plan, and you'd get those results too.

You might be able to handle that with conditions, e.g. if you have specific TCER naming conventions or other ways to distinguish them.

Else, you could try using a dual relationship path - enable multiple paths, with the Merge option, and branch at the TCER as follows:
QM Test Plan > Rel: Reported By > QM Test Execution Record > Rel:Current Test Case result > QM Test Result
[QM Test Plan > Rel: Reported By > QM Test Execution Record] > Rel: Runs Test Case: QM Test Case

There might be other relationship paths as well. Just consider the relationships as you get to each artifact in the path.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.