Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: start and manage GUI tests from within the Qt application #6618

Closed
devos50 opened this issue Dec 3, 2021 · 3 comments
Closed

Comments

@devos50
Copy link
Contributor

devos50 commented Dec 3, 2021

Currently, we use pytest to start, run, and manage the GUI tests. pytest starts the Qt application and closes it when the tests are done. At the moment, we see that our GUI tests are unstable. I suspect that this is partly caused by the combination of Qt and pytest when running the tests. Therefore, I believe it is worthwhile to explore an alternative approach: run the GUI tests from within the Qt application itself. The main motivation for this approach is to remove an element that could be interfering with the GUI tests, namely the pytest infrastructure.

This would work as follows: we can add an addition flag, e.g., --gui-tests to the run_tribler.py script. This flag indicates that Tribler should start in GUI test mode and execute the GUI tests. Tribler will read the methods in the test_gui.py file and extract the methods which name start with test_. When the tests are done, Tribler will be closed automatically and exit with either process exit code 0 (all tests passed) or exit code 1 (one of the tests have failed). This approach would require some logic to identify and run the tests. We should also explore support for code coverage, and printing tracebacks when one of the tests have failed.

Advantages of this approach:

  • We sidestep the need for pytest to run the GUI tests, removing an element that might be interfering with the GUI tests. In the long term, this should lead to more stability when executing the GUI tests.
  • If we modify our build pipeline, we can also run these tests in frozen mode. This can help us to debug GUI glitches that only occur in a frozen environment and/or on specific platforms.

Disadvantages of this approach:

  • We need to write some additional logic to execute GUI tests ourselves (since we cannot use the pytest infrastructure anymore).
  • It is more work to execute a single test or a few select tests. This situation, however, does not occur often in my experience and we can always implement support for this later.

I have implemented a prototype of this approach in a branch, see here.

@kozlovsky
Copy link
Contributor

I was able to fix the stability of the GUI tests; the PR will be ready in two hours. Probably, it is good to keep the ability to run GUI tests from pytest.

On the other side, I like the idea of the possibility of running tests in frozen mode. It may be really useful in some situations!

@qstokkink
Copy link
Contributor

You could consider bundling your tests in a unittest.TestCase to avoid writing your own test_ name matching. The unittest module has all sorts of functions available to automatically load or find tests for TestCases (e.g., unittest.TestLoader.loadTestsFromTestCase). This is fully compatible with pytest.

@drew2a drew2a modified the milestones: 7.12.0, 7.13.0 Oct 14, 2022
@drew2a drew2a modified the milestones: 7.13.0, 7.14.0 Nov 7, 2022
@qstokkink
Copy link
Contributor

Tribler now has a web-based front end and this issue is no longer relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants