如何使用Python的工具包API添加步骤,测试用例在拉力赛 [英] how to add steps to testcases in Rally using python toolkit API

查看:169
本文介绍了如何使用Python的工具包API添加步骤,测试用例在拉力赛的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始反弹蟒蛇REST API玩
我试图创建测试用例,但我的问题是,我不知道如何添加步骤和内容添加到这些步骤
有一个JSON格式是什么?

I recently started playing with Rally python REST API I tried to create Test Cases, But the problem I have is, I am not sure how to Add steps and add content to those steps is there a JSON format for that?

请帮我在这

推荐答案

以下是如何做到这一点一个简单的例子:

Following is a brief example of how to do this:

    #!/usr/bin/env python

    #################################################################################################
    #
    #  createtestcasewithsteps.py -- Create a TestCase, add Test Steps
    #
    USAGE = """
    Usage: createtestcasewithsteps.py
    """
    #################################################################################################

    import sys, os
    from pyral import Rally, rallySettings

    my_server      = "rally1.rallydev.com"
    my_user        = "user@company.com"
    my_password    = "password"
    my_workspace   = "My Workspace"
    my_project     = "My Project"

    rally = Rally(my_server, my_user, my_password, workspace=my_workspace, project=my_project)
    rally.enableLogging('createtestcasewithsteps.log')

    # For a TestCase: Name, Method, Type are required;
    # Workspace cannot be specified in the JSON, it defaults to 
    # the logged in account's Workspace setting
    # The TestCase can optionally be associated to a WorkProduct
    # Project and WorkProduct must be object refs to relevant Rally Entity instances.
    # In this example the WorkProduct is a Defect.

    target_project = rally.getProject()
    target_defect_id = "DE4"
    target_defect   = rally.get('Defect', query='FormattedID = %s' % target_defect_id, instance=True)

    testcase_fields = {
             "Project"     : target_project.ref,
             "WorkProduct" : target_defect.ref,
             "Name"        : "Data Import Automated Test 01",
             "Method"      : "Automated",
             "Type"        : "Regression"
           }

    print "Creating Test Case ..."
    testcase = rally.put('TestCase', testcase_fields)
    print "Created  TestCase: %s   OID: %s" % (testcase.FormattedID, testcase.oid)

    # Add Test Case Steps
    #
    for i in range(3):

        input="Step Input for Step: "+str(i)
        expected_result="Expected Result for Step: "+str(i)

        testcasestep_fields = {
            "TestCase"          : testcase.ref,
            "StepIndex"         : i,
            "Input"             : input,
            "ExpectedResult"    : expected_result
        }

        testcasestep = rally.put('TestCaseStep', testcasestep_fields)
        print "===> Created  TestCaseStep: %s   OID: %s" % (testcasestep.StepIndex, testcasestep.oid)

这篇关于如何使用Python的工具包API添加步骤,测试用例在拉力赛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆