Search code examples
resthp-quality-center

Set test parameter in test instance using HP QC REST API


Is there any way to create test instance with parameter using the REST API on QC 11 ?

I have a test in my test plan with some parameters, or just one for the exercise : qc parameters

I want to create using the rest API :

  • A test set in my test lab
  • A test instance in this test set
  • A test run of my test (the one in the plan) in this test instance
  • And be able to set the value of my parameters

I have manage to do the first 3 points. But I can not find how to set the parameter value for my instance. If I create the tests manually it is asked during the add of the test in the instance. And I can find the parameters in the Execution Settings in the Test Instance detail :

test instance details

I have search in the documentation, but didn't find anything about how to set/use theses parameters. I have made GET on every objects, but didn't find them. I also try some urls like :

/test-instances/25378/test-parameters
/test-instances/25378/execution-settings
/test-instances/25378/exec-settings

But they always return 404.

Is there any way to set these parameters values ?


Solution

  • I had same troubles and here is my solution.

    You can query your test parameters as:

    /tests/{id}/test-parameters
    

    And your test instance parameters, which are effectively actual values for those in your test instance, with:

    /test-instances/{id}/step-parameters
    

    For parameter values created via UI it returns like this:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Entities TotalResults="1">
        <Entity Type="step-parameter">
            <ChildrenCount>
                <Value>0</Value>
            </ChildrenCount>
            <Fields>
                <Field Name="origin-test">
                    <Value>-1</Value>
                </Field>
                <Field Name="vc-user-name">
                    <Value></Value>
                </Field>
                <Field Name="id">
                    <Value>21</Value>
                </Field>
                <Field Name="parent-id">
                    <Value>46</Value>
                </Field>
                <Field Name="used-by-owner-type">
                    <Value>test-instance</Value>
                </Field>
                <Field Name="actual-value">
                    <Value>&lt;html&gt;&lt;body&gt;
                        &lt;div align=&quot;left&quot;&gt;
                        &lt;font face=&quot;Arial&quot;&gt;&lt;span style=&quot;font-size:8pt&quot;&gt;AAA&lt;/span&gt;&lt;/font&gt;
                        &lt;/div&gt;
                        &lt;/body&gt;&lt;/html&gt;</Value>
                </Field>
                <Field Name="key">
                    <Value></Value>
                </Field>
                <Field Name="used-by-owner-id">
                    <Value>34</Value>
                </Field>
            </Fields>
            <RelatedEntities/>
        </Entity>
    </Entities>
    

    Where used-by-owner-id is id of the test-instance and parent-id is id of test parameter of the test. Actual value for this case is AAA wrapped up with html tags.

    You can create step parameters like this using normal POST to url:

    /step-parameters
    

    Note: Don't use same nested url for creation as you use for retrieval. You'll not be able to create parameters with such a combination of parameters you need.

    API documentation really sucks, but you can get ideas how to retrieve or create things you need by requesting entity schema with

    /customization/entities