Properties定义不同维度(Suite/testcase)下的测试变量
具体的类型为:Project,TestSuite,TestCase,Global。分别为项目级,测试集级,测试用例级和全局。
以在左侧Custom Properties/或者编辑窗口Properties页签都可以添加变量
加入了参数之后,在测试步骤中可以用以下形式来调用参数。${#作用域#参数名}
比如
${#Project#} 将获取项目中定义的值
${#TestSuite#} 将获取当前测试集中定义的值
${#TestCase#} 将获取当前测试用例中定义的值
通过属性传递抽取一个值 ,再通过DataSink测试步骤或属性写入到一个外部文件
DataGen,允许创建一个计数器、随机值等动态属性
获取测试集的属性值
def username=testRunner.testCase.testSuite.getPropertyValue("username")
testRunner.testCase.testSteps["Properties"].getPropertyValue("userId")
改变测试集属性值
testRunner.testCase.testSteps["HTTP Request"].setPropertyValue("username",username)
在Script Assertion中想要获得属性值的话可以用以下形式替代
def number = messageExchange.modelItem.testCase.testSteps["Properties"].getPropertyValue("userId
正则表达式或
.*(数据库已经存在对应的数据|成功).*
获取系统当前时间
cal = Calendar.instance;
sysdate = cal.getTime().format('yyyy-MM-dd hh:mm:ss');
log.info(sysdate)
参数传递
Data.status_token
Data.[0].NewsId
获取随机数
test${=(long)(Math.random()*200000000000)}@qq.com
1. 依次执行项目下所有的测试用例
testrunner.bat SPG2800-Performance-soapui-project.xml –r
2. 依次执行TestSuite下所有的测试用例
testrunner.bat SPG2800-Performance-soapui-project.xml -s SPG2800_Test -r
3.执行指定的测试用例
testrunner.bat SPG2800-Performance-soapui-project.xml -c TestCase_ADD_SBR -r
soapUI 提供了一个命令行工具 testrunner.bat 来运行一个项目中的 TestSuite, 可以在 <soap_ui_home>/bin 下找到它, 它的使用非常简单,只需要设置下面的几个常用参数即可:
-s 指定要运行的 TestSuite
-f 指定运行结果的输出目录
-j 生成 junit 风格的 report
-r 运行完成以后打印一个简单的 summary
下面这行命令就是运行 bookstore.xml 这个 soapUI 项目中的 BookstoreTestSuite, 把结果输出到 c:\temp\reports 中。
testrunner.bat -sBookstoreTestSuite -r -j C:\developerWorks\soapui\bookstore.xml -f c:\temp\reports
有了 testrunner,把 soapUI 的测试集成到 BuildForge 中就很简单了,只需要在 BuildForge 的项目中添加一个步骤
Running SoapUI TestRunner for [LearningCloud]
directory: D:\Program Files (x86)\SmartBear\SoapUI-Pro-5.1.2\bin\.
"D:\Program Files (x86)\SmartBear\SoapUI-Pro-5.1.2\bin\"testrunner.bat -j -fC:\soapuiLog -o -R"JUnit-Style HTML Report" -EDefault -I -S "D:\02.soapUI5.1.2 workspace\LProject-sit -new\soapui-project.xml"
脚本断言验证响应时间
def StandardResponseTime= context.expand( '${#Project#responseTime}' ) as long
def ActualResponseTime = messageExchange.timeTaken as long
log.info(ActualResponseTime+' '+StandardResponseTime)
assert ActualResponseTime < StandardResponseTime
脚本步骤设置当前日期
cal = Calendar.instance;
sysdate = cal.getTime().format('yyyy-MM-dd hh:mm:ss');
log.info(sysdate)
//testRunner.testCase.testSteps["Properties"].setPropertyValue('curTime', sysdate)
//testRunner.testCase.setPropertyValue('curTime', sysdate)
testRunner.testCase.testSuite.setPropertyValue('curTime', sysdate)
数据库请求SQL语句传参select top 1 * from dbo.T_Biz_Plan where PlanId = :planId
wsdl和wadl有哪些区别
wadl是用来添加备份的resource,wsdl是用来添加wsdl服务的