• 接口,自动化,java--L


    1.  前端,后端
        *** 接口:后端接口测试(功能测试)
        ***  前端测试:手工测试、功能测试
      (浏览器、app、微信公众号、小程序、h5页面) --》
        ***  根据域名,查看ip
      ping  域名(有时候不管用)
        *** 文件资源:图片(服务器--》电脑)
      js、CSS文件
      
        *** 数据传递:注册数据、请求一个宝贝列表
      》后端程序--》接口(函数) --》逻辑处理 》反馈--》响应(有格式的字符串,json、 xml) --》前端--》服务
      http:/ / Www . xxx. com/ pub1ic/ images/ logo . png  等效于
      http://120.78.xxx.25/ public/ images/ 1ogo . png
      1:
      确定一个主机--》请求到哪里去》www.lemfix. com--》 dns解析--》主机ip--》120.78.xxx.25
      端口:默认: 80
      2:
      UI层面测试非常薄弱--》黑盒测试
      服务层--》接口
      白盒测试--》程序员--》单元测试 
    2.   java,代码,发送请求
        *** 工具
      //接口自动化--》第三方的框架、工具: java net、HttpClient
        ***  执行我们一个接口测试用例: 步骤
      1:请求链掖、接口地址: http://120.78. xxx.25:8080/xxx/mvc/ api / member/
      2:请求参数: mobilephone= 13666666666, pwd=123456,regname=tom
      3:请求方式: get、post
      4:调用工具进行发包--》发数据包、发起一个请求
      5:响应--》把返回的数据提取出来
      6:断言--》判断--》看最后的结果是否符合预期结果--》如果符合,测试通过,香则规试不通过
    3.  java,get,post:发送
      public class Main {
      public static void main(String[] args) throws IOException {
      http_get();
      http_post();
      }
      //---------------------------------------------------------------------------------------------------------
      public static void http_get() throws IOException {
      // 1:请求链接、接口地址: http://120. 78.xx.25: 8080/futureloan/ mvc/ api/ member/register
      String url = "http://120.78.xx.25:8080/futureloan/mvc/api/member/register";
      url += "?mobilephone=13666666666&pwd=123456&regname=tom";
      HttpGet get = new HttpGet(url);

      HttpClient httpClient = HttpClients.createDefault();
      HttpResponse response = httpClient.execute(get);
      String result = EntityUtils. toString(response.getEntity());
      System.out.println(result);
      System.out.println("this is get " );
      }
      public static void http_post() throws IOException {
      // 1:请求链接、接口地址: http://120. 78.xx.25: 8080/futureloan/ mvc/ api/ member/register
      String url = "http://120.78.xx.25:8080/futureloan/mvc/api/member/register";

      HttpPost post = new HttpPost(url);
      List<NameValuePair> parameters = new ArrayList<NameValuePair>() ;
      parameters. add(new BasicNameValuePair( "mobilephone", "18300000000"));
      parameters . add(new BasicNameValuePair("pwd", "123456"));
      parameters . add(new BasicNameValuePair("regname", "tom"));
      post.setEntity(new UrlEncodedFormEntity(parameters));

      HttpClient httpClient = HttpClients.createDefault();
      HttpResponse response = httpClient.execute(post);
      String result = EntityUtils. toString(response.getEntity());
      System.out.println(result);
      System.out.println("this is post " );
      }
      }
    4.  
    ------------------------这是用来做笔记的,可能不够详细,如有问题可以留言-------------------------
  • 相关阅读:
    C++ 与 C 的预处理能力
    unicore32linuxgcc 预定义宏
    内核中的原子上下文
    ConText
    PREEMPT_ACTIVE
    对象和类
    java的getClass()函数
    堆栈以及对象的引用
    public、protected、default、private作用域
    android 环境变量搭建
  • 原文地址:https://www.cnblogs.com/focusta/p/12187272.html
Copyright © 2020-2023  润新知