Basic use python + pytest (running test report & tests)

import pytest 

test run # 1 contains the name of a string
test # Name contains the add
# perform: add test_assert.py pytest -k

# 2. lengthy reduction operation test
# perform: pytest -q test_assert.py

# 3. If a test case fails, quit test
# perform: pytest -x test_assert.py

# 4. run the test directory relative or absolute path will do
# perform: pytest ./test_dir

# 5. specify the test class or method performing
# specify operation test_fixtures_02.py test_multiply_5_6 method in the class file TestMultiply
# file name, between the class name and method name in line with the partition ::
# perform: pytest test_fixtures_02.py::TestMultiply::test_multiply_5_6

# through 6. the main ( ) test method run
# IF the __name__ == '__main__':
# IF the __name__ == '__main__':
# pytest ([ '- S', '. / test_dir'])

# generate a test report
# 1. generate JUnit XML file
# execute:. pytest ./test_dir --junit-xml = / report / log.xml

# 2. Generate test reports online
# perform: pytest ./test_dir --pastebin = all

# 3.pytest-html test report may be generated in HTML format 
# install the install pytest-HTML PIP
# perform:. Pytest ./ --html = / report / result.html

Guess you like

Origin www.cnblogs.com/Teachertao/p/11902087.html