15 tsung 断言

在<request>标签下的<match>标签,可以校验服务器的响应,根据校验结果执行不同的操作。任何情况下,只有响应匹配了我们设置字符串,则match数将增加,如果不匹配, nomatch数将会增加。

一、统计断言成功次数

例如,如果服务器响应内容包含了Welcome !,则继续往下执行,同时,match计数增加!

<request>

   <match do="continue" when="match">Welcome !</match>

   <http url="/login.php" version="1.0" method="POST"

         contents="username=nic&amp;user_password=sesame"

         content_type="application/x-www-form-urlencoded" >

</request>

do="continue"表示什么事都不做,仅仅统计次数

当when=match或者when=nomatch成立的时候,我们有以下几种不同的操作:

continue: do nothing, continue (only update match or nomatch counters)

log: log the request id, userid, sessionid, name in a file (in match.log)

abort: abort the session(中止会话)

restart: restart the session. The maximum number of restarts is 3 by default.

loop: repeat the request, after 5 seconds. The maximum number of loops is 20 by default.

dump: dump the content of the response in a file. The filename is match-<userid>-<sessionid>-<requestid>-<dumpid>.dump

 

二、只断言响应内容,过滤掉响应头

<request>

   <match do="continue" when="match" skip_headers='http'>Welcome !</match>

   <http url="/login.php" version="1.0" method="POST"

         contents="username=nic&amp;user_password=sesame"

         content_type="application/x-www-form-urlencoded" >

</request>

三、校验响应内容的md5值:

<match do='log' when='nomatch' skip_headers='http' apply_to_content='ts_digest:md5hex'>01441debe3d7cc65ba843eee1acff89d</match>

<http url="/" method="GET" version="1.1"/>

四、使用动态变量校验

<match do='log' when='nomatch' subst='true' >%%_myvar%%</match>

<http url="/" method="GET"/>

五、1.5版本之后新特性,可以在报告中命名匹配统计的名称

<match do='log' when='match' name='http_match_200ok'>200OK</match>

<http url="/" method="GET" version="1.1"/>

六、常用统计功能举例:

xml文件配置:

可以在生成报告中查看:

 

转载于:https://www.cnblogs.com/pymi/p/9145877.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值