python自动化测试——pytest用例执行顺序

import pytest

class TestCase():
    def setup_class(self):
        print("setup_class:所有用例执行之前")

    def setup_method(self):
        print("setup_method:  每个用例开始前执行")

    def teardown_method(self):
        print("teardown_method:  每个用例结束后执行")

    def teardown_class(self):
        print("teardown_class:所有用例执行之后")

    def test_A(self):
        print("用例A")
        assert True

    def test_B(self):
        print("用例B")
        assert True

pytest -s testOrder.py --html=report.html

执行顺序

setup_class:所有用例执行之前
setup_method: 每个用例开始前执行
用例A
.teardown_method: 每个用例结束后执行
setup_method: 每个用例开始前执行
用例B
.teardown_method: 每个用例结束后执行
teardown_class:所有用例执行之后

猜你喜欢

转载自www.cnblogs.com/nicole-zhang/p/10385115.html