[RC3] Sikuli IDE's unit test feature and the alternatives
- Last updated by:
- RaiMan on on 2013-10-27
***** Section relevant for RC3
based on questions like:
and the known restrictions/bugs in the feature:
-- import not supported as expected
-- tests performed in reverse order
-- hangs when tests have syntax errors
*** So for more sophisticated scenarios use Python's unittest feature directly and run your scripts normally in IDE or with option -r from command line.
***** end section for RC3 only
***** the rest is valid too for version 1.0.1+ -------
For the basics on the following examples have a look at the docs at
Take Care: things marked as available 2.6 or later might not be available in Sikuli's Jython 2.5.2
*** backport unittest2
There is a package unittest2 available in the net, that makes it possible to use features from 2.6 and 2.7 (e.g. skip tests) in Python prior versions. Since it is written in Python language only, it can be used with Sikuli.
**** a template for unit test cases separated in .sikuli scripts
(you might put everything in one script as well ;-)
--- in each of your modUnitTestx.sikuli
at the beginning of each script put:
from sikuli import *
indent the rest of the script one level, so that all the def's belong to your TestCase class.
In this class put a bunch of "def testxxxx(self):" and may be setUp and tearDown.
so for this example you might have:
# script modUnitTestA.sikuli
--- create a mainTest.sikuli
as a base template, to get a feeling:
from modUnitTestA import * # supposing, scripts live in same directory
suite = unittest.
loads all def()'s from class UnitTestA which is in modUnitTestA.
**** a test runner, that produces HTML output
I have a modified version, that stores a screenshot on failure, that you can look at with a link in the HTML result page.
**** a tip for Hudson/Jenkins (from: https:/
I recommend Jython/Python unittests instead of the sikuli-special version.
I use an Python TestRunner that outputs JUnit-XML testresultfiles that can e.g. be used by Hudson/Jenkins.
You can find a working xmltestrunner here:
You can use it like this:
from xmlrunner import *
suite = unittest.
result = XMLTestRunner(
**** Sikuli and RobotFrameWork
*** to be continued