测试技能

作者: 钱嘉鑫 | 来源:发表于2018-04-09 21:06 被阅读19次

简单介绍一下需要掌握的一些技能。

版本管理工具 git

简介

这个是用来管理代码版本滴,
还记不记得以前写毕设的时候


35b32c381f30e924f097309649086e061c95f7a5.jpg

是不是很痛苦?

那git就是专门帮你解决这个问题的。

Quick Start

初级用法

# 从服务器克隆代码仓库到本地(可选git地址或者http地址)
git clone git@xxx.git (http://xxx.git)

# 从服务器拉去最新代码到本地
git pull / git fetch;git rebase

# 添加文件/修改到版本库(git帮你暂时管理你的修改)
git add

# 提交文件/修改到版本库(记录为一次修改)
git commit

# 推送你的修改到服务器
git push

中级用法

# 创建一个分支
git branch

# 切换一个分支
git checkout

# 打标签
git tag

Tips

git擅长管理文本文件(比如 *.java*.sql*.md等),不擅长管理文档和二进制文件(比如 *.doc*.class等)

结构化查询语言 SQL

Quick Start

table_student

id student_name age sex
001 张三 19 male
002 李四 20 female

table_course

id course_name
001 计算机原理
002 SQL基础

table_score

id student_id course_id score
001 001 001 89
002 001 002 75
003 002 001 96
004 002 002 83

初级用法

# 查询
select * from table_student where sex = 'male';

# 新增
insert into table_student ('id', 'student_name', 'age', 'sex') values ('003', '王五', '19', 'male');

# 更新
update table_student set age = '20' where id = '003';

# 删除
delete from table_student where id = '003';

中级用法
查询 成绩大于85分的学生姓名,课程名称及成绩

# 连接查询
select tst.student_name, tc.course_name, tsc.score from table_score tsc 
left join table_student tst on tsc.student_id = tst.id 
left join table_course tc on tsc.course_id = tc.id 
where tsc.score > '85';

# 子查询
select tst.student_name, tsc.score from table_student tst
where tst.id in (
  select tsc.student_id from table_score tsc where tsc.score > '85');

额,子查询这个还居然没做出上面那个题。

Tips

某些关键字
group by, order by, limit, top, distinct
常用函数也要了解一些
sum(), count(), split(), concat(), now()

JAVA

事前准备

maven

简介

项目管理工具,帮助开发人员管理依赖,构建项目,编译打包。
使用groupId, artifactId, version来唯一描述一个组件。
想要依赖什么组件,可以去maven中央仓库http://mvnrepository.com/去搜索

下载地址

idea自带

配置文件描述

项目目录内,名称叫pom.xml
文件结构

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    //项目基本信息
    <groupId>com.study</groupId>
    <artifactId>demo</artifactId>
    <packaging>jar</packaging>
    <version>0.0.1</version>

    //项目依赖
    <dependencies>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>fluent-hc</artifactId>
            <version>4.5.5</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>3.10.0</version>
        </dependency>
    </dependencies>
</project>

fluent

简介

是基于http client封装的流式调用框架,使用简单易上手,底层还是使用的http client,但是由于http client配置众多,且没有处理各种参数,不利于上手。

maven依赖

<dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>fluent-hc</artifactId>
      <version>4.5.5</version>
</dependency>

Quick Start

Response execute = Request.Get("http://suggest.taobao.com/sug?code=utf-8&q=袜子")
            .addHeader("Cache-Control", "no-cache")
            .addHeader("Postman-Token", "f09b1101-d290-4fe3-a808-0f5419776a66")
            .execute();
System.out.println(execute.returnContent());

okhttp

简介

安卓端最火热的轻量级框架,由移动支付Square公司贡献(该公司还贡献了Picasso和LeakCanary) 。用于替代HttpUrlConnection和Apache HttpClient(android API23 里已移除HttpClient)。

maven依赖

<dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>okhttp</artifactId>
        <version>3.10.0</version>
</dependency>

Quick Start

OkHttpClient client = new OkHttpClient();

        Request request = new Request.Builder()
            .url("http://suggest.taobao.com/sug?code=utf-8&q=%E8%A2%9C%E5%AD%90")
            .get()
            .addHeader("Cache-Control", "no-cache")
            .addHeader("Postman-Token", "b94ae5ec-d66c-4788-a8b3-8b04d5e21fd0")
            .build();

        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());

RestTemplate

Python3

requests

安装

pip install requests

Quick Start

import requests

url = "http://suggest.taobao.com/sug?code=utf-8&q=袜子"

headers = {
    'Cache-Control': "no-cache",
    'Postman-Token': "f09b1101-d290-4fe3-a808-0f5419776a66"
    }

response = requests.request("GET", url, headers=headers)

print(response.json())

由于这是一个返回json结果的接口,所以可以通过response.json()获取到结果并且转换为python对象:

{
    'result': [
        ['袜子夏女短', '3.384287016698948'],
        ['袜子男袜纯棉', '3.335294696474566'],
        ['袜子女 纯棉', '2.669109684479514'],
        ['袜子 女 夏 棉', '3.344201567342065'],
        ['袜子 女 脚底袜', '3.346865473786668'],
        ['袜子,短袜', '3.3564156689996323'],
        ['袜子婚', '3.362803607922915'],
        ['袜子  女 夏', '3.3789773256222904'],
        ['袜子 薄款 女', '3.3858545534843776'],
        ['袜子童女', '3.3143186984498856']
    ]
}

针对这样的python对象,采用不同的业务解析逻辑,可将不同的接口串联在一起。
不同的接口不知道怎么填入参数或者cookie,可以配置好postman,使用code gen功能生成python代码。

http.client

相关文章

网友评论

    本文标题:测试技能

    本文链接:https://www.haomeiwen.com/subject/qnegrttx.html