在Pytest> test_suit.py中,即使我仅创建一个类的对象,它也会收集所有测试

问题: Pytest收集所有测试用例。

LinearLayoutManager layoutManager = new LinearLayoutManager(getcontext(),RecyclerView.HORIZONTAL,false) {

            @Override
            public void onScrollStateChanged(int state) {
                super.onScrollStateChanged(state);

                if (state == RecyclerView.SCROLL_STATE_IDLE) {
                        // your logic goes here
                    }
                }
            }
        };
#test_suit.py

import unittest
from tests.susi.test_sign_in import TestLoginTypeone
from tests.susi.test_sign_up import TestSignUp

# Get all tests from the test classes
tc1 = unittest.TestLoader().loadTestsFromTestCase(TestLoginTypeone)


# Create a test suite combining all test classes
smokeTest = unittest.TestSuite([tc1])

unittest.TextTestRunner(verbosity=2).run(smokeTest)

在跑步时:#test_sign_in.py import utilities.custome_logger as cl import unittest import pytest from pages.susi.login_page import TypeoneUser,TypeTwoUser import logging @pytest.mark.usefixtures("oneTimeSetUp","setUp") class TestLoginTypeone(unittest.TestCase): log = cl.customLogger(logging.DEBUG) @pytest.fixture(autouse=True) def objectSetup(self,oneTimeSetUp): self.lp = TypeoneUser(self.driver) @pytest.mark.run(order=1) def test_valid_user(self,): self.log.info("*#" * 20) self.log.info("User login started") self.log.info("*#" * 20) self.lp.userLogin_Typeone() @pytest.mark.run(order=2) def test_validate_login(self): self.lp.verifyLogin() @pytest.mark.usefixtures("oneTimeSetUp","setUp") class TestLoginTypeTwo(unittest.TestCase): log = cl.customLogger(logging.DEBUG) @pytest.fixture(autouse=True) def objectSetup(self,oneTimeSetUp): self.lpt = TypeTwoUser(self.driver) @pytest.mark.run(order = 1) def test_valid_login(self): self.log.info("*#" * 20) self.log.info("User login started") self.log.info("*#" * 20) self.lpt.userLogin_TypeTwo() @pytest.mark.run(order=2) def test_validate_login(self): self.lpt.verifyLogin()

终端结果:

pytest -v -s test\test_suit.py

任何人都可以帮助为什么发生这种情况吗? 运行test_suit.py时,即使我仅调用一个测试用例,它也会收集所有测试。我已经尝试了所有pytest文档,但没有从这些文档获得任何帮助

longxin0118 回答:在Pytest> test_suit.py中,即使我仅创建一个类的对象,它也会收集所有测试

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3152912.html

大家都在问