简体   繁体   English

使用HP QC REST API在测试实例中设置测试参数

[英]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 ? 有什么方法可以使用QC 11上的REST API使用参数创建测试实例吗?

I have a test in my test plan with some parameters, or just one for the exercise : 我的测试计划中有一个带有某些参数的测试,或者只是一个用于练习的参数: QC参数

I want to create using the rest API : 我想使用其余的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 : 我可以在“测试实例”详细信息的“执行设置”中找到参数:

测试实例详细信息

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. 我已经对每个对象进行了GET,但是没有找到它们。 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. 但是他们总是返回404。

Is there any way to set these parameters values ? 有什么方法可以设置这些参数值?

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: 对于通过UI创建的参数值,其返回如下:

<?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. 其中used-by-owner-id是测试实例parent-idparent-id是测试的测试参数的ID。 Actual value for this case is AAA wrapped up with html tags. 在这种情况下,实际值是AAA ,上面加上html标签。

You can create step parameters like this using normal POST to url: 您可以使用普通的POST来创建类似以下的步骤参数来输入网址:

/step-parameters

Note: Don't use same nested url for creation as you use for retrieval. 注意:请勿使用与检索相同的嵌套url进行创建。 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 API文档确实很烂,但是您可以通过请求实体模式来获得有关如何检索或创建所需内容的想法

/customization/entities

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM