Main Content

addRequirementLink

Add requirement traceability link to local OSLC test resource object

Since R2021a

    Description

    example

    addRequirementLink(testResource,requirementURL) adds an RDF/XML element to the test case or test script resource specified by testResource. The function sets the element name to oslc_qm:validatesRequirement and the rdf:resource attribute to requirementURL. Use the commit function to apply the change to the service provider. For more information about RDF/XML elements, see An XML Syntax for RDF on the World Wide Web Consortium website and QM Resource Definitions on the Open Services for Lifecycle Collaboration (OSLC) website.

    Examples

    collapse all

    This example shows how to add, remove, and get OSLC requirement resources linked to a test case resource with a previously configured OSLC client.

    After you have created and configured an OSLC client myClient as described in Create and Configure an OSLC Client for the Quality Management Domain, create a query capability for the test case resource type.

    myQueryCapability = getQueryService(myClient,'TestCase');

    Submit a query request to the service provider for the available test case resources.

    testCases = queryTestCases(myQueryCapability)
    testCases = 
    
      1×5 TestCase array with properties:
    
        ResourceUrl
        Dirty
        IsFetched
        Title
        Identifier

    Retrieve the requirement resources linked to one of the test cases. Fetch the resource properties from the service provider for the test case.

    myTestCase = testCases(1);
    fetch(myTestCase,myClient);
    reqs = getRequirementLinks(myTestCase)
    reqs = 
    
        Requirement with properties:
    
        ResourceUrl: 'https://localhost:9443/rm/resources/_aQ1gRg8bEeuLWbFe'
              Dirty: 1
          IsFetched: 0
              Title: ''
         Identifier: ''

    Remove the existing link to the requirement resource from the test case resource. Commit the changes to the service provider.

    removeRequirementLink(myTestCase,reqs.ResourceUrl);
    status = commit(myTestCase,myClient)
    status = 
    
      StatusCode enumeration
    
        OK

    To add a link to a requirement, in the OSLC service provider, locate the requirement resource that you want to link to the test case resource. Identify the resource URL. Create a variable URL and set the value of the variable to the requirement URL that you found in the service provider.

    URL = 'https://localhost:9443/rm/resources/_oJNtgWrqEeup0a6t';

    Create a traceability link between the requirement resource and the test case. Commit the change to the service provider.

    addRequirementLink(myTestCase,URL);
    status = commit(myTestCase,myClient)
    status = 
    
      StatusCode enumeration
    
        OK

    View the test case in the system browser.

    show(myTestCase)

    Input Arguments

    collapse all

    OSLC test resource, specified as an oslc.qm.TestCase or oslc.qm.TestScript object.

    Requirement or requirement collection resource URL, specified as a character vector.

    Version History

    Introduced in R2021a