Software testing (interface testing & business scenario testing)

software test

Manual testing

8 elements of test cases

  • serial number
  • Use case name (title)
  • module
  • priority
  • precondition
  • Test Data
  • Steps
  • expected outcome

Interface testing (simulating http requests)

Interface use case design

  1. Prevent missing tests
  2. Conveniently assign tools to assess workload and time
  3. Interface test test points
    • Function
      • single interface
      • Business scene
    • performance
      • response generation
      • compatibility
      • Concurrency
      • Server data utilization
    • safety
      • Attack security
      • business security
10 elements of interface test case documentation
  • serial number
  • Use case name (title)
  • module
  • priority
  • precondition
  • Request method
  • url
  • Request header
  • Request body (request data)
  • expected outcome

1. Single interface test

  1. numerical value
    • forward
    • reverse
  2. parameter
    • forward
      • required
      • Optional
      • all
    • reverse
      • multiple parameters
      • Less ginseng
      • No ginseng
      • Wrong parameters

2 Business scenario testing

How users use it to test, analyze interface documents to write test cases, and use the postman tool to view response data

Use postman management, execute test cases, and generate test reports

Test point: Log in first>>>>Add employee>>>>Query employee>>>>Modify>>>>In query>>> >Delete>>>>Check whether deletion is successful

Test case writing

postman tool

1. Tool usage
  1. Introduction
  2. Install
  3. Case: get, post request, use interface documents, developer tools, fiddler to obtain http data
2. Use postmanpostman management, execute test cases, and generate test reports
  1. Import, everywhere use case collection

  2. postman's assertions to implement automated testing

    1. Assert response status code

      //断言响应状态码是否为200
      //pm:postman的实例
      //test():postman的方法,两个参数
      //			参数1:" "断言结束后的文字提示
      //			参数2:一个匿名函数(功能:pm的响应结果中应该包含状态码200),pm.response.to.have.status(200);函数体
      pm.test("status code is 200",function(){
              
              
          pm.response.to.have.status(200);
      });
      
    2. Assert whether the response body contains a mog string

    3. Assert whether the response body is a mog string (object)

    4. Assert json data

    5. Assert response header

  3. Global variables and local variables

    //全局变量
    pm.globals.set("var_name",value);
    //环境变量
    pm.environment.set("var_name",value);
    

postman request pre-script

It is executed immediately after clicking send. Postman internally sends it before the http request.

  1. Set timestamp
//拿到时间戳代码,设置到全局变量中
var timestamp = new Date().getTime();

//发送请求时携带过去
pm.globals.set("glb_timestamp",timestamp)
  1. Use time global variables
  2. Schematic:

Insert image description here

postman association

  1. Purpose: Used when there is data association or dependency between multiple http requests.
  2. Implementation steps (A interface depends on the value of B interface):
    • B interface sends http request to obtain data
    • Set data to global variables (environment variables)
    • A interface obtains the data values ​​in global (environment) variables for use
//获取全部响应结果中
var jsonData = pm.response.json()
//从响应结果中获取城市名
var city = jsonData.weatherinfo.city
//将城市名写到全局变量中
pm.globals.set("glb_city",city)

Guess you like

Origin blog.csdn.net/weixin_52154534/article/details/134917482