zoukankan      html  css  js  c++  java
  • soapUI中多个TestCase之间传递参数

    <p>---恢复内容开始---</p>
     在SoapUI中可以定义一个个的测试用例TestCase,但是有些用例是依赖于之前的用例的,如果纯拷贝的话可能会导致用例比较臃肿而且不好维护,比如说存在如下两个TestCase:
      1)CreateUserTestCase:测试创建用户,通过发送Soap报文方式创建用户同时需要校验数据库中值是否正确
      2)ChangUserInfoTestCase:测试修改用户信息,通过发送Soap报文方式修改用户信息,需要校验修改前和修改后的用户信息
      ChangUserInfo之前必须得创建一个用户,纯拷贝肯定是不可取的,因为后续如果创建用户的接口稍有变动,则需要同时在ChangUserInfoTestCase和CreateUserTestCase修改请求报文。
      SoapUI在TestCase中提供Run TestCase的Step,可以直接调用指定的TestCase,但是需要前一个TestCase中将属性传递出来,步骤如下:
      1)在被调用TestCase中设置返回属性
      testRunner.testCase.setPropertyValue("属性名称",“属性值”)
      2)在调用TestCase中增加Run TestCase指向被调用TestCase
      3)在调用TestCase中的其它Test Step中获取属性
      例如:在CreateUserTestCase中将创建好的用户ID传给ChangUserInfoTestCase,则步骤如下:
      1)在CreateUserTestCase中通过Groovy Script. 设置返回属性:
      testRunner.testCase.setPropertyValue("UserID",context.getProperty("UserID"))
      2) 在ChangUserInfoTestCase中增加Run TestCase:RunNewUserTestCase指向CreateUserTestCase并指定UserID属性为输入值
      3)在ChangUserInfoTestCase中获取执行CreateUserTestCase得到的用户ID
    def NewUserProperties = testRunner.testCase.getTestStepByName( "RunNewUserTestCase" );
    log.info(NewUserProperties .getPropertyValue( "UserID" ))

    本文出自 wendy-qian 的51Testing软件测试博客:http://www.51testing.com/?15017055
    http://www.blogjava.net/qileilove/archive/2014/01/16/409011.html<p>---恢复内容结束---</p>
     在SoapUI中可以定义一个个的测试用例TestCase,但是有些用例是依赖于之前的用例的,如果纯拷贝的话可能会导致用例比较臃肿而且不好维护,比如说存在如下两个TestCase:
      1)CreateUserTestCase:测试创建用户,通过发送Soap报文方式创建用户同时需要校验数据库中值是否正确
      2)ChangUserInfoTestCase:测试修改用户信息,通过发送Soap报文方式修改用户信息,需要校验修改前和修改后的用户信息
      ChangUserInfo之前必须得创建一个用户,纯拷贝肯定是不可取的,因为后续如果创建用户的接口稍有变动,则需要同时在ChangUserInfoTestCase和CreateUserTestCase修改请求报文。
      SoapUI在TestCase中提供Run TestCase的Step,可以直接调用指定的TestCase,但是需要前一个TestCase中将属性传递出来,步骤如下:
      1)在被调用TestCase中设置返回属性
      testRunner.testCase.setPropertyValue("属性名称",“属性值”)
      2)在调用TestCase中增加Run TestCase指向被调用TestCase
      3)在调用TestCase中的其它Test Step中获取属性
      例如:在CreateUserTestCase中将创建好的用户ID传给ChangUserInfoTestCase,则步骤如下:
      1)在CreateUserTestCase中通过Groovy Script. 设置返回属性:
      testRunner.testCase.setPropertyValue("UserID",context.getProperty("UserID"))
      2) 在ChangUserInfoTestCase中增加Run TestCase:RunNewUserTestCase指向CreateUserTestCase并指定UserID属性为输入值
      3)在ChangUserInfoTestCase中获取执行CreateUserTestCase得到的用户ID
    def NewUserProperties = testRunner.testCase.getTestStepByName( "RunNewUserTestCase" );
    log.info(NewUserProperties .getPropertyValue( "UserID" ))

    本文出自 wendy-qian 的51Testing软件测试博客:http://www.51testing.com/?15017055
    http://www.blogjava.net/qileilove/archive/2014/01/16/409011.html

  • 相关阅读:
    关于DotNETStruts
    SQL语句导入导出大全
    一个打印Dataset的.net的打印类
    遍历指定文件夹下所有的文件
    SQL Server SQL导入导出语句
    查看OCX的属性和方法的脚本
    关于写文本文件的问题
    新钶信息系统面试
    【POJ1208】The Blocks Problem
    【POJ1363】Rails
  • 原文地址:https://www.cnblogs.com/molly8124-tech/p/4213478.html
Copyright © 2011-2022 走看看