Secondary packaging and optimization based on Unitest and Pytest automated testing framework

1. Comparison of test frameworks

There are many unit testing frameworks in the Python technology stack. We mainly consider mainstream frameworks, because these frameworks have powerful functions, sound documentation, and strong community support. If you encounter any problems during use, you can quickly find solutions or technical support .

There are three common testing frameworks:

1. unittest framework

unittest is a testing framework in the standard library that comes with Python, and it is sometimes called PyUnit. Engineers who have used Java may think of JUnit, and unittest is equivalent to the Python version of JUnit.

2. nose frame

The nose framework is a third-party module that needs to be installed separately and is simpler to use than unittest. The nose framework can automatically identify test units inherited from unittest.TestCase and execute tests, and it can also test test units that do not inherit from unittest.TestCase. The nose framework provides a rich API for writing test codes.

The nose framework has many built-in plug-ins, which can help testers to capture output results, find errors, code coverage, document testing (Doctest), etc. If you don't like the functions provided by these built-in plug-ins, or these plug-ins cannot meet the project structure, you can customize the development of plug-ins to complete the required functions.

3. pytest framework

pytest is a third-party testing framework, which mainly has the following characteristics:

  • Simple to use, flexible and easy to get started.
  • Support parametric programming.
  • It can support functional tests of various complexity (from simple to complex), and can also work with other automation frameworks such as Selenium or Appium to complete interface automation testing.
  • With third-party plug-ins, you can customize extensions, such as pytest-selenium for integrating Selenium, pytest-

Guess you like

Origin blog.csdn.net/qq_35029061/article/details/130051382