From 8dcaae58ace44bddccba0119fa98e62a573d2c7f Mon Sep 17 00:00:00 2001 From: drew2a Date: Mon, 29 Apr 2024 15:54:46 +0200 Subject: [PATCH] Add dependency management to GUI tests Introduced pytest-dependency and pytest-order packages to manage dependencies between GUI tests. This allows for more controlled execution of test cases, ensuring that certain tests run before others. The 'test_downloads' function is now marked as a dependency for other related test functions, enforcing the order in which they are executed. --- .github/workflows/vars/pytest.env | 2 +- requirements-test.txt | 2 ++ src/tribler/gui/tests/test_gui.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/vars/pytest.env b/.github/workflows/vars/pytest.env index a6b123199ad..ec486589494 100644 --- a/.github/workflows/vars/pytest.env +++ b/.github/workflows/vars/pytest.env @@ -10,7 +10,7 @@ PYTEST_TUNNELS_ARGUMENTS_WIN='${PYTEST_TUNNELS_ARGUMENTS}' PYTEST_TUNNELS_ARGUMENTS_LINUX='${PYTEST_TUNNELS_ARGUMENTS} --looptime' PYTEST_TUNNELS_ARGUMENTS_MAC='${PYTEST_TUNNELS_ARGUMENTS} --looptime' -PYTEST_GUI_ARGUMENTS='./src/tribler/gui ${PYTEST_ARGUMENTS}' +PYTEST_GUI_ARGUMENTS='./src/tribler/gui ${PYTEST_ARGUMENTS} --order-dependencies' PYTEST_GUI_ARGUMENTS_WIN='${PYTEST_GUI_ARGUMENTS}' PYTEST_GUI_ARGUMENTS_LINUX='${PYTEST_GUI_ARGUMENTS} --looptime' PYTEST_GUI_ARGUMENTS_MAC='${PYTEST_GUI_ARGUMENTS} --looptime' diff --git a/requirements-test.txt b/requirements-test.txt index e61f493dfd8..e63cac04efa 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -6,6 +6,8 @@ pytest-asyncio==0.21.1 pytest-randomly==3.15.0 pytest-timeout==2.2.0 pylint-pytest==1.1.7 +pytest-dependency==0.6.0 # for GUI tests +pytest-order==1.2.1 # for GUI tests coverage==7.3.2 looptime==0.2 ; sys_platform != 'win32' diff --git a/src/tribler/gui/tests/test_gui.py b/src/tribler/gui/tests/test_gui.py index 4ace0bbfec2..ed2bad2a0c6 100644 --- a/src/tribler/gui/tests/test_gui.py +++ b/src/tribler/gui/tests/test_gui.py @@ -323,6 +323,7 @@ def test_settings(window): wait_for_signal(window.settings_page.settings_edited) +@pytest.mark.dependency def test_downloads(window): go_to_and_wait_for_downloads(window) screenshot(window, name="downloads_all") @@ -336,6 +337,7 @@ def test_downloads(window): screenshot(window, name="downloads_inactive") +@pytest.mark.dependency(depends=["test_downloads"]) def test_download_start_stop_remove_recheck(window): go_to_and_wait_for_downloads(window) QTest.mouseClick(window.downloads_list.topLevelItem(0).progress_slider, Qt.LeftButton) @@ -346,6 +348,7 @@ def test_download_start_stop_remove_recheck(window): QTest.mouseClick(window.downloads_page.dialog.buttons[2], Qt.LeftButton) +@pytest.mark.dependency(depends=["test_downloads"]) def test_download_details(window): go_to_and_wait_for_downloads(window) QTest.mouseClick(window.downloads_list.topLevelItem(0).progress_slider, Qt.LeftButton)