qileilove

blog已经转移至github,大家请访问 http://qaseven.github.io/

soapUI中多个TestCase之间传递参数

 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

posted on 2014-01-16 11:17 顺其自然EVO 阅读(3973) 评论(0)  编辑  收藏 所属分类: web 前端性能测试


只有注册用户登录后才能发表评论。


网站导航:
 
<2014年1月>
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

常用链接

留言簿(55)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜