51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1766|回复: 4
打印 上一主题 下一主题

[原创] Day5-5测试积点任务

[复制链接]
  • TA的每日心情
    无聊
    昨天 09:38
  • 签到天数: 493 天

    连续签到: 3 天

    [LV.9]测试副司令

    跳转到指定楼层
    1#
    发表于 2018-7-12 10:38:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    1测试积点
    问题:
    Post 请求用 postman 构造时能正常响应,相同的参数用 rest assured 请求却提示参数格式异常,哪位大神能帮忙看下?
    1.如下是用postman构造的request,此api要同时传查询参数和body.postman构建请求返回为200.

    2.用restassured构造相同的请求,所有 参数完全一致,甚至参数名都是直接复制的,但总是提示参数格式异常。

    个人怀疑问题出在传递的body中,因为另外一条只有body请求的api也call不通,传递的body和这条内容 是一样的。这个问题困扰我2天了
    1. ' public Response registerDevice(String strSWAccess2,String type,String serial,String deviceId,String sig,String ctr,String nounce) throws Exception {
    2. givenWhetherNeedToLoginWithLID("yes");
    3. JSONObject body=new JSONObject();
    4. body.put("modelType",type);
    5. body.put("sn",serial);

    6. givenAnUrl(baseUrl+registerDevicePath);
    7. //用Lambda表达式,用父类中带参数的方法发Request,并拿回Response
    8. super.whenSendRequestWithMethod("post",x -> {

    9. x.cookie("SWAccess", strSWAccess).
    10. queryParam("deviceId", deviceId.trim()).
    11. queryParam("ctr", ctr.trim()).
    12. queryParam("nounce", nounce.trim()).
    13. queryParam("sig", sig.trim()).
    14. contentType("application/json").body(body).
    15. header("Cache-Control","no-cache");

    16. return x;
    17. });
    18. System.out.println("registerDevice return code:"+actualResponse.statusLine());
    19. return actualResponse;
    20. }
    21. '
    22. '
    23. public void whenSendRequestWithMethod(String httpMethod, IFunc iFunc){

    24. switch (HttpMethod.getHttpMethod(httpMethod)){
    25. case GET:
    26. actualResponse = iFunc==null?get((strURL)):iFunc.ISpecifyParams4HttpRequest(given()).get(strURL);
    27. strResponse = actualResponse.asString();
    28. break;

    29. case POST:
    30. //actualResponse = iFunc==null?given().contentType(JSON).body(strRequestBody).post(strURL):iFunc.ISpecifyParams4HttpRequest(given()).contentType(JSON).body(strRequestBody).post(strURL);
    31. actualResponse = iFunc==null?given().log().all().post(strURL):iFunc.ISpecifyParams4HttpRequest(given().log().all()).post(strURL);
    32. strResponse = actualResponse.asString();
    33. break;

    34. case PUT:
    35. actualResponse = iFunc==null?put(strURL):iFunc.ISpecifyParams4HttpRequest(given().log().all()).put(strURL);
    36. strResponse = actualResponse.asString();
    37. break;

    38. case DELETE:
    39. actualResponse = iFunc==null?delete(strURL):iFunc.ISpecifyParams4HttpRequest(given().log().all()).delete(strURL);
    40. strResponse = actualResponse.asString();
    41. break;

    42. default:
    43. actualResponse =iFunc==null?get(strURL): iFunc.ISpecifyParams4HttpRequest(given().log().all()).get(strURL);
    44. strResponse = actualResponse.asString();
    45. break;
    46. }

    47. logger.info("Response = " + strResponse);
    48. }
    49. '
    复制代码


    附件: 您需要 登录 才可以下载或查看,没有帐号?(注-册)加入51Testing
    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    昨天 07:25
  • 签到天数: 2772 天

    连续签到: 3 天

    [LV.Master]测试大本营

    2#
    发表于 2018-7-13 10:11:45 | 只看该作者
    报文头是否有差别?
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2021-12-27 08:30
  • 签到天数: 471 天

    连续签到: 1 天

    [LV.9]测试副司令

    3#
    发表于 2018-7-13 10:34:43 | 只看该作者
    应该是报文头之间的问题
    回复

    使用道具 举报

  • TA的每日心情
    慵懒
    昨天 10:29
  • 签到天数: 1481 天

    连续签到: 3 天

    [LV.10]测试总司令

    4#
    发表于 2018-7-13 11:00:31 | 只看该作者
    看下报文头里面的session 等信息
    回复

    使用道具 举报

  • TA的每日心情
    慵懒
    2022-7-23 11:23
  • 签到天数: 316 天

    连续签到: 1 天

    [LV.8]测试军长

    5#
    发表于 2018-7-13 14:04:04 | 只看该作者
    看不懂,posman没用过呢
    回复

    使用道具 举报

    本版积分规则

    关闭

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

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

    GMT+8, 2024-9-21 04:34 , Processed in 0.063028 second(s), 22 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

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