当前位置:网站首页>Pytest automated testing - compare robotframework framework

Pytest automated testing - compare robotframework framework

2022-07-01 04:39:00 Horse killing chicken test

  One 、 Preface

The test framework Is to help us manage test cases 、 Execute test case 、 A parameterized 、 Assertion 、 Basic work such as generating test report ,

Let's focus on writing test cases . A good testing framework should be highly extensible , Support secondary development , And can support a variety of types of automated testing .

Testing tools Is to complete a certain type of test , such as Selenium Used to deal with WEB UI Conduct automated tests ,Appium Used to correct APP Conduct automated tests ,Jmeter It can be used for API Automated testing and performance testing .

in addition ,Java In language OkHttp library ,Python In language requests library , these HTTP Of client It can also be seen as a kind of API Testing tools .


Two 、 Frame comparison

Robot Framework

Robot Framework It's based on Python Of , Extensible Keyword Driven Automation test frame , For end-to-end acceptance testing and acceptance test driven development (ATDD).

advantage :

1) Enable easy to use Table Syntax , Create test cases in a unified way .

2) Provides the creation of reusable... From existing keywords Higher level keywords The function of .

3) Provide easy to read result The report and HTML Format log .

4) Provides a simple library API, Used to create Custom test library

5) Provide tags to classify and select test cases to execute .

shortcoming :

1) Fixed form of tabulation , Complicates a lot of simple grammar , And it doesn't support complex syntax , inflexible , And it's not conducive to improving the code writing ability of testers , And it's easy to write fatigue .

2) Test data and test code are interleaved into the same file 、 In the same way , There's tight coupling , Will result in modification of test data or test code , May affect each other , It is not conducive to the maintenance of test data and test scripts .

Pytest】 

Pytest  yes Python It's easy to use 、 Efficient and flexible Unit test framework , Can support unit and functional testing .

advantage :

1) Easy to use , Easy entry , The document is rich , There are many examples in the document .

2) Support simple unit testing and complex functional testing .

3) Be able to execute all test cases , You can also select some test cases to execute , And it can automatically Retrying failed use cases .

4) Support Concurrent execution , It can also run by nose, unittest Test cases written .

5) have A lot of third-party plug-ins , And you can customize the extension .

shortcoming :

1) Because of pure Python To write , It needs testers to have certain ability of code writing and reading

2)Pytest There is no intuitive use case to display and browse the page itself , We need to show the distribution of use cases with the help of third-party modules ( such as Allure)

  Writing rules :

  • Test file with test_ start ( With _test The ending is OK )
  • Test class to Test start , And not with init Method
  • Test function to test_ start
  • Assertions use basic assert that will do

Commonly used decorators :


3、 ... and 、 The new framework explains

 

Pain points to solve :

1) Method ( keyword ) There are too many references in , Easy to confuse 、 Use confusion

2) Method encapsulation level is simple , Too much repetitive code , This leads to bloated automation use cases ( One or two hundred lines )

3) The function of the method is single , There are too many general methods , Inconvenient to use (redis Seven or eight ways to query )

4) As more and more use cases , Cannot execute concurrently , The total execution time is too long ( A few hours )

5) The test data is fixed , Too little parameterization , Too much dependence on the environment , Can't expand ( Unable to switch between provinces and cities )


Four 、         New automation flow chart

1、  Automatic operation flow chart

2、  Interface verification flow chart

3、 Flow chart of database verification

原网站

版权声明
本文为[Horse killing chicken test]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202160248210751.html