51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 1968|回复: 1

[原创] 接口性能测试

[复制链接]

该用户从未签到

发表于 2019-8-15 15:25:28 | 显示全部楼层 |阅读模式
代码编写思路:
!、加挂研发代码jar包
2、获取请求体参数名称并赋值
3、调用研发代码请求方法
4、添加请求头
5、添加请求体

           String phone = lr.eval_string("<NewParam>");
           String smsContent = "Welcome to Hexin Short Message Group Chat developed by China Mobile";
           String conversationId = lr.eval_string("<phone>");
           String appId = "csmsa.cmcc.template.sms";
           String msgSeqId = lr.eval_int("<msgSeqId>")+"";
           String shareKey = "csmsa.cmcc.template.sms";
           String srcid = lr.eval_string("<srcid>");
           String templateId = "cmcc.template.sms.none";
           String templateVersion = "1.0.0";
           String replyReference = "http://xx.xx.xx.xx:xxxx/test/submit";
             InitializeClass initializeClass = new InitializeClass();
             Submit submitData = initializeClass.getSubmitData(new String[]{"http://test.com",
                appId,msgSeqId,shareKey,
                "12520009"+srcid,smsContent,
                "extmsgid","group.invite",templateId,templateVersion,
                replyReference ,conversationId,
                "1","+861340210"+phone});
             //SubmitHeader header = new SubmitHeader();
             SubmitHeader header = submitData.getSubmitHeader();
             String token = header.getToken();
             String timestamp = header.getTimestamp();
           web.add_header("appid",appId);
           web.add_header("timestamp",timestamp);
           web.add_header("msgSeqId",msgSeqId);
           web.add_header("token",token);
           web.add_header("Content-Type","application/json;charset=utf-8");
           lr.rendezvous("submitData");
        lr.start_transaction("事物开始");
          web.custom_request("preview",
                               "Method=POST",
                               new String[]{
                                   "URL=http://xx.xxx.xx.xx:xxxx/sms/submit",
                                   "Body="+submitData.getBody(),
                                   "TargetFrame=",
                                   "RecContentType=application/json",
                                   "LAST"});
        lr.end_transaction("事物开始", lr.AUTO);
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-3-29 23:22 , Processed in 0.063507 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表