程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python+requests+yaml implementation of interface automation use case (2) -- upgraded version

編輯:Python

One 、 Preface : It took a while for the interface automation testing framework encapsulated a while ago to find that there are still many drawbacks , At present, it has been improved , It can be said that the whole idea has been overthrown , It is much more powerful than before , If you are interested, please send me a private letter to communicate with you alone , Hope to learn and make progress together !

Two 、 Project directory

 

 

 

case Catalog : Store test execution files

config Catalog : Store the configuration file ( Database connection information 、token Information, etc )、 Temporarily stored files ( You need to extract the fields of the interface to use )

data Catalog : Store test case data files

files Catalog : Store accessories ( The upload interface requires )

log Catalog : Store the generated log file

logs Catalog : Encapsulated logs

report Catalog : Deposit allure Test report

utils Catalog : Secondary packaging requests、 Database connection 、 Assertion 、 General methods, etc

conftest.py: Method to perform initialization , This is mainly when the test case collection is completed , What will be collected item Of name and nodeid The Chinese language of is displayed on the console

main.py: The main entry of the program

pytest.ini: To configure pytest Test the rules executed by the framework

readme.md: Some descriptions of interface automation test framework

requestsirements.txt: Some third-party libraries that need to be installed

3、 ... and 、 The core idea ( Use a specific example to illustrate ):

 

 

 

 

 

 

 

 

 

  First, execute case Test cases in the directory py file , Then read the corresponding data Test cases maintained under , And then call utils Lower encapsulated requestUtil class , Execute check_case().requestUtil Under the package request、 assert methods . See the screenshot code for details . The general idea is like this , Please study by yourself .

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  For special reasons , Some screenshots are incomplete , You can use your ideas for reference , No need to copy .

 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved