Tried intergrating pytest-dependency and pytest-ordering in my testcases that are in different python files and issue below rises where dependent testcases are skipped. Seen similar issues here in stackoverflow but this could be a unique one.
test_mod_01.py
import pytest
from pages.Page1 import LaunchPage
@pytest.mark.usefixtures("setup")
class TestPage1:
@pytest.mark.dependency()
@pytest.mark.run(order=1)
def test_page1(self):
pass
self.lp = LaunchPage(self.driver)
self.lp.clickButton1()
test_mod_02.py
import pytest
import softest
from flaky import flaky
from pages.Page2 import TalentPage
from pages.Page3 import CVPage
@pytest.mark.usefixtures("setup")
class TestPage2_3(softest.TestCase):
@flaky(max_runs=3, min_passes=2)
@pytest.mark.dependency(depends=["testcases/test_mod_01.py::TestPage1::test_page1"], scope="session")
@pytest.mark.run(order=2)
def test_page2(self):
self.tp = TalentPage(self.driver)
self.tp.scroll_down()
self.tp.clickButton2()
self.tp.clickButton3()
@flaky(max_runs=3, min_passes=2)
@pytest.mark.dependency(depends=["TestPage2_3::test_BuildCV_page_2"], scope="session")
@pytest.mark.run(order=3)
def test_page3(self):
self.cvp = CVPage(self.driver)
self.cvp.clickButton4()
self.cvp.clickButton5()
self.cvp.clickButton6()
self.cvp.clickButton7()
Conftest
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.edge.service import Service as EdgeService
from webdriver_manager.microsoft import EdgeChromiumDriverManager
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager
@pytest.fixture()
def setup(request, browser):
if browser == "chrome":
options = webdriver.ChromeOptions()
options.add_argument("--disable-notifications")
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options)
elif browser == "firefox":
options = webdriver.FirefoxOptions()
options.add_argument("--disable-notifications")
driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()), options=options)
elif browser == "edge":
options = webdriver.EdgeOptions()
options.add_argument("--disable-notifications")
driver = webdriver.Edge(service=EdgeService(EdgeChromiumDriverManager().install()), options=options)
driver.get("https://example.com/")
driver.maximize_window()
request.cls.driver = driver
yield request.cls.driver
request.cls.driver.quit()
def pytest_addoption(parser):
parser.addoption("--browser")
@pytest.fixture(scope="session", autouse=True)
def browser(request):
return request.config.getoption("--browser")
Error
(venv) xxxx % pytest -v -s --browser chrome testcases
=============================================================== test session starts ===============================================================
platform darwin -- Python 3.11.4, pytest-7.4.3, pluggy-1.3.0 -- xxxx
cachedir: .pytest_cache
rootdir: xxxx
plugins: flaky-3.7.0, dependency-0.5.1, ordering-0.6
collected 3 items
testcases/test_mod_01.py::TestPage1::test_page1 PASSED
testcases/test_mod_02.py::TestPage2_3::test_page2 SKIPPED (test_page2 depends on testcases/test_...)
testcases/test_mod_02.py::TestPage2_3::test_page3 SKIPPED (test_page3 depends on TestP...)
========================================================== 1 passed, 2 skipped in 14.66s ==========================================================
Even when i combine the test_mod_01 with test_mod_02 in one class, the independent testcase runs and other two are skipped. Tried to initialize the test_mod_01 class in test_mod_02 and run, but still wont work.