zoukankan      html  css  js  c++  java
  • 接口自动化测试-Mock Get和Post请求

    Mock可以模拟一个http接口的后台响应,可以模拟request,response 

    下载 moco-runner-0.11.0-standalone.jar

    下载链接: https://pan.baidu.com/s/1bmFzvJPRnDlQ-cmuJ_3iRg 提取码: kpjv

    确保安装了jdk,cmd下可以运行java -version

    一、模拟不带参的get请求

    #代码中的description行可以不写;一般结构为description,request,response,除description外,其它值均为键值对形式;request定义uri(接口地址),method(请求方式),queries 或 forms;

    参考代码: 

    [
    {
    "description":"this is a no param get",
    "request":{
    "uri":"/get",
    "method":"Get"
    },
    "response":{
    "text":"Yeah,you sucess"
    }

    }
    ]

     二、模拟带参数的get请求;

    参数使用"queries"

     三、发送不带参数Post;

    post请求不能使用浏览器访问,可以使用Postman或Jmeter工具;

     浏览器访问结果如下:

     Postman设置及结果如下:

    Jmeter设置及结果如下:

     四、发送带参数的Post请求;参数使用"forms"

     Postman设置及结果如下图;键值(key,value)都传对了,status才显示200,否则显示400;

     jmeter设置及结果如下图;

    越努力,越幸运!!! good good study,day day up!!!
  • 相关阅读:
    Linux 技巧:让进程在后台可靠运行的几种方法
    What is /dev/null 2>&1?
    In the shell, what does “ 2>&1 ” mean?
    Linux命令之umask
    /dev/null简介
    What is special about /dev/tty?
    sed用法
    cobbler 更换dns和dhcp服务器为dnsmasq
    Linux下如何退出vim的一些常用命令总结
    nginx部署vue项目
  • 原文地址:https://www.cnblogs.com/canglongdao/p/12174046.html
Copyright © 2011-2022 走看看