Problem: Pytest collecting all test cases.
#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()
while running: pytest -v -s test\test_suit.py
Result in Terminal:
Collected 2 items
Can anyone help why this is happening? While running test_suit.py it is collecting all tests even though I am calling only one testcase. i have tried all pytest docs but didn't get any help from these docs
Aucun commentaire:
Enregistrer un commentaire