pytest-common plugins

Commonly used plugins

Plug-in one: pytest test report

  • Install library
    • pip install pytest-html
  • Instructions
    • Add parameters in the configuration file
    • addopts = -s --html = report/report.html

Use directly on the command line: pytest -q test01.py --html=html/test01.html

Plug-in 2: pytest control function execution order

  • Install library
    • pip install pytest-ordering
  • Instructions
    • Add before the use case being executed
    • @pytest.mark.run(order=num)
    • Use @pytest.mark.run(order=num)
    • The order of execution is as follows
    • 0> positive number> no modification> negative number

Priority: 0> Smaller positive number> Larger positive number> No mark> Smaller negative number> Larger negative number

Plug-in 3: Control the number of failed retries

  • Install library
    • pip install pytest-rerunfailures
  • Instructions
    • Add a new parameter in the command line parameters in the configuration file --reruns=10

The principle of use case rerun after failure:

When the use case fails to rerun, if the execution passes within the number of reruns, the remaining reruns will no longer be executed

Guess you like

Origin blog.csdn.net/qq_36875803/article/details/109232017