cucumber & rest assured做接口测试

前面的blog给了对应的工程,这个文章是对实现的功能做补充说明。

工程地址:cucumber工程下载,包含selenium和restassured_mengh2016的博客-CSDN博客

1. cucumber脚本。

2. Rest Assured对应的实现。

cucumber脚本说明:

@RestAssuredCase
Feature: test feature test
  Scenario: test assured aw
    When I send a get request with url "http://localhost:8080/usertwo/getUser?id=11111"
    Then the response status should be "200"

  Background:
  Given set base url and set header
  """
    {"accept-encoding": "gzip,deflate","accept-language":"zh-CN"}
  """
    Scenario Outline:
      When I send a get request with url "http://localhost:8080/usertwo/getUser?id=11111"
      Then the JSON response "<jsonPath>" equals "<value>"
      Examples:
        | jsonPath | value |
        |code      |200    |

  Scenario: test post request
    When I send a POST request to "/save" and request json:
    """
    {
    "bookid": "5433",
    "bookname": "Effective Java",
    "author": "Joshua Bloch",
    "price": "670"
}
    """

    Then state code will be "200"
    And the JSON response "bookid" equals "5433"
  Scenario: test put with param
    When I get book with "1" and "test"
    Then response code should be 200 and header should be:
    """
{"Content-Type":"application/json","Transfer-Encoding":"chunked","Keep-Alive":"timeout=60","Connection":"keep-alive"}
    """

实现的功能:

1. post方法

脚本如下:

When I send a get request with url 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值