background
Some of our formal code is written in Python, and this part of the code needs TDD, so we need to find a useful test framework. Framework Selection
Python's Test Tools encyclopedia:
Https://wiki.python.org/moin/PythonTestingToolsTaxonomy
Python Mainstream testing tools for horizontal comparisons
http://docs.python-guide.org/en/latest/writing/tests/
http://pythontesting.net/test-podcast/
According to the following article, we decided to use the Pytest
Http://mathieu.agopian.info/presentations/2015_06_djangocon_europe/?full#cover
Official information of Pytest
integration of http://wiki.zte.com.cn/pages/viewpage.action?pageId=38150854 CI
Normal pytest installation is not covered by coverage
Pip Install Pytest
Pytest coverage requires additional installation
Pip Install Pytest-cov
At this time, the new Py.test command, which is the original Pytest command on the basis of encapsulation, new coverage features.
Example Demonstration:
Py.test test_conf2bin.py--junit-xml=test_conf2bin_report.xml--cov-report=html--cov-config=.coveragerc--cov=./
Test_conf2bin.py is the target test file –junit-xml=test_conf2bin_report.xml is the test_conf2bin_report.xml–cov-report=html that generates the JUnit format The report –COV-CONFIG=.COVERAGERC the output HTML uses the. COVERAGERC configuration file (Py.test is based on coverage.py and therefore supports coverage.py configuration files)
–cov=./this is necessary, without this, will be unable to output HTML report
. Coveragerc This file allows Py.test to implement more advanced features, as follows:
[Run]
Branch = True
[the]
include = conf2bin.py
[HTML]
directory = Python_coverage_report
[The]
Include = conf2bin.py
Because Py.test accounting for all the files in a folder, if you only need statistics conf2bin.py the coverage of this file, you can write
[HTML]
Directory = Python_coverage_report
Refers to the HTML output folder last
Pytest personal trial, indeed very good, more than the test frame with a strong