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

Add helpers for application testing #44

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

benzea
Copy link

@benzea benzea commented Apr 5, 2018

I am currently working on adding testing to g-c-c and would also like to streamline the code for g-s-d. For this, I worked on the two classes in these commits, and I was wondering whether it might be feasible to merge at least the X11 helper into dbusmock in some form.

@benzea
Copy link
Author

benzea commented Apr 5, 2018

Example of using both:

import os
import sys
import unittest
import dbusmock

BUILDDIR = os.environ.get('BUILDDIR', os.path.join(os.path.dirname(__file__)))

class PanelTestCase(dbusmock.X11SessionTestCase, dbusmock.GTest):
    g_test_exe = os.path.join(BUILDDIR, 'test-network-panel')

if __name__ == '__main__':
    # avoid writing to stderr
    unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=2))

Which runs Xvfb, and the system + session busses to execute each of the tests in the binary separately.

@benzea benzea force-pushed the master branch 5 times, most recently from 162cc87 to c253847 Compare April 10, 2018 14:27
Benjamin Berg added 3 commits April 11, 2018 13:23
This test will automatically start up Xvfb and both a system and session
bus. This can be useful for testing UI application.
This is just a simple wrapper that allows calling test binaries created
with the GLib testing infrastructure and produces nicer output. In
particular, the output will only be printed if the test failed.

There is fallback code which will simply run the binary as is.

@staticmethod
def make_tests(exe, result):
test = subprocess.Popen([exe, '-l'], stdout=subprocess.PIPE, stderr=PIPE_DEVNULL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ran into the problem today that this particular execution is done without an X11 server started, which means that it can fail if the process needs X11 to initialise.

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

Successfully merging this pull request may close these issues.

2 participants