Is there a way to specify which pytest tests to run from a file?

前端 未结 8 569
长情又很酷
长情又很酷 2020-12-12 11:05

Is there a way to select pytest tests to run from a file? For example, a file foo.txt containing a list of tests to be executed:

tes         


        
8条回答
  •  执笔经年
    2020-12-12 11:43

    You can use -k option to run test cases with different patterns:

    py.test tests_directory/foo.py tests_directory/bar.py -k 'test_001 or test_some_other_test'
    

    This will run test cases with name test_001 and test_some_other_test deselecting the rest of the test cases.

    Note: This will select any test case starting with test_001 or test_some_other_test. For example, if you have test case test_0012 it will also be selected.

提交回复
热议问题