Skip to content

GUI Testing Requirements

andresriancho edited this page Jan 17, 2013 · 1 revision

Introduction

Simple wiki page to help me decide which GUI testing environment I’ll use for w3af.

Requirements

Got seven requirements, each one receives a 1-10 importance multiplier. Then, each testing framework receives a 1-10 score for each requirement and finally the total score for a testing framework is calculated like multiplier_1 * req_score_1 + … + multiplier_7 * req_score_7

  • Mainstream: If everybody uses X, it will be part of Python one day and receive support and even more attention (like the [http://www.voidspace.org.uk/python/mock/ Mock] module).
  • Pure-Python: It’s a plus if I don’t have to learn any new (external) tool and all tests can be defined in pure-python.
  • Maintainable: Tests need to be maintainable. Warning: Tools based on screenshots.
  • Based on unittests: If based on unittests module it is more likely that I’ll be able to run the tests with nosetests or any other tool that runs unittests.
  • Easy to code: New tests shouldn’t take more time than coding the window I’m testing
  • Can be run without X windows: This is an important thing but I realize that it might not be possible. Depending on X means that when running the tests you have to leave the screen alone to avoid interfering with the test. Also, tests can not be run at the same time.
  • Community support
  • Does the tool have a community and/or company that supports it?
  • Is the tool maintained? When was the latest release/svn commit?

Comparison

Testing framework Mainstream(10) Pure-Python(8) Maintainable(7) Based on unittests(10) Easy to code(8) Without X(9) Community support(9) Total Score
LDTP 10 10 10 9 10 10 8 582
unittest + twisted's trial 5 10 10 10 8 10 5 499
mago (based on LDTP) 8 10 10 10 10 10 0 500
guitest 0 10 8 10 7 10 1 391
Xpresser 5 8 1 8 6 6 5 348
StoryText 5 5 8 5 5 5 4 317
sikuli 8 1 5 1 7 1 5 243

Comments

  • guitest is too old and unmaintained, discarding as it might be a solution but won’t scale in the long run.
  • unittest+trial sounds interesting, used by Canonical. Not well documented, but it works. More focused on unittest than functional testing.
  • LDTP is great, but it is more functional testing than unit-testing. Maybe the solution is to merge LDTP and unittest+trial?
  • mago is based on LDTP, has good documentation on how to run tests in [http://mago.ubuntu.com/Documentation/RunningOnHudson Hudson with xvfb]. Still need to understand the advantages of using mago instead of LDTP. The mago project is not supported anymore
  • Xpresser tests seem too fragile, if I re-arrange the widgets in a window (but don’t change anything else) they will fail. Tests are not that easy to code since I have to take screenshots of everything I want to focus on, click x-N pixels from a location, etc.

Final decision

Failed

We’ll use LDTP for functional testing of w3af’s GTK UI because:

  • The active community and development
  • Good documentation
  • Pure-Python
  • Depends on a11y which is a stable API
  • Based on python’s unittest module

The only concern, which will require more research is how to run LDTP tests in xvfb. This proved to be a deal breaker that made me move to dogtail.

If needed we’ll use unittest+trial for unit testing UI modules.

Now

Using dogtail, see the After the decision was made... section.

After the decision was made...

  • [http://ldtp.freedesktop.org/wiki/RecordHOWTO RecordHOWTO] says that we should use something called LDTPEditor which [http://download.freedesktop.org/ldtp/movies/gcalctool-record.ogg looks very cool and useful] but in the mailing list they say [http://lists.freedesktop.org/archives/ldtp-dev/2010-August/001010.html it is deprecated]. The solution is to “use the API available in LDTP (like getobjectlist, getobjectproperty etc)”.

  • Created [https://sourceforge.net/apps/trac/w3af/browser/branches/threading2/core/ui/gtkUi/tests/ldtp_wrapper/sniff.py?rev=6006 my own sniff].

  • Started to play around with LDTP and after some failures sent an [http://lists.freedesktop.org/archives/ldtp-dev/2012-October/001187.htmlemail to the mailing list]. I recommend you read through the whole thread. The summary is that LDTP doesn’t recognize any DISPLAY environment variables; which breaks my requirements of running tests on the same box using Xvfb.

  • After some more searching I found the dogtail project, which was very similar to LDTP AND it supported the DISPLAY environment variable. I'm writing a wrapper around this tool at the moment of writing these lines. The objective is to be able to run dogtail tests with nosetests, which seems to work!

References

Calculate total score

def calc(scores):
    mult = (10,8,7,10,8,9,9)
    total = 0
    assert len(mult) == len(scores)
    for i in xrange(len(scores)):
        total += scores[i] * mult[i]
    return total

print calc((0,10,8,10,7,10,1))