How do you test a GUI application?

I haven’t “unit-tested” or “tested” any of my program, whether they have a GUI or not. I manually test each and every part of my program, including bottle-neck cases and find if it is doing things correctly. But after reading and seeing a lot of modules, testing (using code, not manually) seems important. So I decided to start the journey with Gtk applications, I wrote.

But how do you do that? All the examples I could find are doing something like this:

test_my_func(test=(func, arg), expected=("Hello",))

Its okay and simple for programs or modules, where the values basically revolve around numbers, strings or custom-yet easy objects. But in GUI programs, this isn’t case, how can I know if my app runs perfectly and if user got the right widget, at the right position in correct shape? Doing the expected and observed comparisons here would be pretty long.
Because, I believe, that a GUI applications working depends mostly on users’ interaction and can’t be checked by “running codes”. They should be tested by running the app and manually testing out various components.

But I’m afraid I’m wrong. So based on your experiences, how do you test Gtk applications? I use Python, so any language-oriented help is also welcome.

There are various tools:

  • OpenQA tests a whole environment, but it can be used for applications. It’s big and complex, but deals with “this application matches the reference” cases
  • Dogtail does functional testing on applications through the accessibility stack

There is no great solution for testing GUI apps; my suggestion is to code the logic separately and then test it as a white box separately from the GUI bits; if the internal logic works, the GUI is typically not going to be a problem, assuming there’s no real logic left on the UI side.

1 Like