rest assured

添加maven坐标

<dependencies>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>3.3.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

demo

//given开头表示输入数据
        given().log().all()
                //query请求参数
                .queryParam("code", "sogo")
                //头信息
                .header("Cookie","_ga=GA1.2.506579530.1552574503; device_id=0158c91c7ecd8e4d248a54002af6d8ae; aliyungf_tc=AQAAAIatGzFrQgoAJGDMeOsikkxtPFqv; xq_a_token=682c39a460645dafb1ff41f67e0efccba8b0f118; xq_a_token.sig=Bg9acTC-woVSsS6DZvdAtd40CQU; xq_r_token=798a7cab8cd606f61a09fbac15374f1172b00607; xq_r_token.sig=sHSWFNmu_GqEUOK9A-6umfNgFcU; _gid=GA1.2.841306833.1553178554; Hm_lvt_1db88642e346389874251b5a1eded6e3=1552574504,1552736056,1553178554; u=881553178554746; _gat=1; Hm_lpvt_1db88642e346389874251b5a1eded6e3=1553180196")
                //when表示触发条件
                .when()
                .get("https://xueqiu.com/stock/search.json")
                //then对结果断言
                .then()
                //打印log
                .log().all()
                //断言状态码
                .statusCode(200)
                //字段断言
                .body("stocks.name",hasItems("搜狗"))
                .body("stocks.code",hasItems("sogo"));
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值