Interface automation framework thinking and source code

Thinking^Organizing ideas

思考这么几个问题:我想做一个什么样的自动化平台?用什么方式去实现?怎么去完成我的这个想法?

Before doing this, ask yourself as many questions as possible. This kind of thinking can make your thinking gradually clear. Then I began to look forward to the fact that the entry for writing use cases for this platform should be saved separately, so that it would be relatively convenient to maintain the use cases; a center for converting use cases is needed to convert the written use cases into a program recognition, must read the json format; an assembly is required Where the use case is, the use case is packaged and the strategy is run; a function to save test results is needed; the saved results need to be notified to followers in time. I think about as many questions as possible, not necessarily at once. The basic idea can be simply sorted out: after
Insert picture description here
having an idea, it will be easy, and start to code according to what you have learned.

Use Case Maintenance Center

Use case maintenance is nothing more than excel, database, csv, yaml and other formats. It's just that the storage format is different, I chose the yaml format. What needs to be included in the use case? Reference options: use case number, pre-processing, use case name, interface address, interface request method, parameters, dependent use cases, expected results, post-processing, etc. It's nothing more than enough of these things, it doesn't matter if it's not all, it's necessary to add it in use. Of course, most of the interface data requires parameterized functions, you need to query the database to fetch data, and you may also need to write your own function personalized parameters, etc., which need to be taken into account when designing, and a good hole is reserved. Use keyword-driven, just write according to the format that needs to be used.

- CaseNo: 1  ------------------------------------------------用例编号
  Extract:   ------------------------------------------------用例变量,用例中需要用到的变量在这里面定义,调用--形如:$变量$
    biz_no:  ------------------------------------------------生命变量名,需要使用用两个$包起来,支持自定义函数、数据库查询、常量等
  Preposition: -----------------------------------------依赖用例编号
    - 1
  ProjectName: 模块名字 ---------------------------------------模块名
  CaseNmae: 功能描述---------------------------------------用例名
  Method: post  -------------------------------------------接口请求方式
  param: --------------------------------------------------参数标识
      method: 接口
      bizContent:
        taskNoList:
        - key: $biz_no$ -------------------------------------使用变量
          value: sql-apv_wf:select * from where a='$biz_no$' --是用变量 并操作数据库查询替换,数据库格式入sql-库名:
          remark: $1$:res["flag"]---------------------------------------------------使用依赖用例结果
        toUser: $user$ ----------------------------------------使用变量
  headers: ---------------------------------------------------header标识
    Cookie: $headers$ ---------------------------------------使用变量
  ExpectedResults: -----------------------------------------断言标识,list格式,暂时支持数据库比较、接口结果比较。list第一个值实际结果,第二值为预期结果(接口比较入:-res['flag'] - S)
    - sql-apv_wf: select user_no from wf_task
    - xiaoming

Configuration Center

Writing test cases may need to use database operations, running use cases may need to select multiple environments, etc. This kind of thing is best stored in a file for maintenance.

Out of the box

Code

The portal
is used out of the box to
edit the use case online to
view the test report and the
front and back ends are separated

Guess you like

Origin blog.csdn.net/kairui_guxiaobai/article/details/115182853