python - Pytest - run multiple tests from a single file -
i'm using pytest (selenium) execute functional tests. have tests split across 2 files in following structure:
my_positive_tests.py
class positive_tests: def test_pos_1(): populate_page() check_values() def test_pos_2(): process_entry() validate_result()
my_negative_tests.py
class negative_tests: def test_neg_1 populate_page() validate_error()
the assertions done within functions (check_values, validate_result, validate_error). i'm trying find way run tests single file, main test file like:
my_test_suite.py
test_pos_1() test_pos_2() test_neg_1()
then command line execute:
py.test --tb=short "c:\pycharmprojects\my_project\mytest_suite.py" --html=report.html
is possible this? i've been searching , haven't been able find out how put calls tests in single file.
you don't have run tests manually. pytest finds , executes them automatically:
# tests/test_positive.py def test_pos_1(): populate_page() check_values() def test_pos_2(): process_entry() validate_result()
and
# tests/test_negative.py def test_neg_1(): populate_page() validate_error()
if run
py.test
they should automatically picked up.
you can select single file
py.test -k tests/test_negative.py
or single test
py.test -k test_neg_1
Comments
Post a Comment