← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #201012]: Simply Unit Testing not working - or is it me?

 

Question #201012 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/201012

    Status: Open => Answered

RaiMan proposed the following answer:
Ok, what you are writing in Sikuli script IS actually Python.

I do not want to hinder you, to use the Sikuli IDE feature. 
But the experience is: after the first successful tests people start to ask for many features, that are not possible in this test environment by design.

But in the normal run environment of the IDE, everything is possible,
that is supported by Jython 2.5 (the Java based Python interpreter
Sikuli uses internally).

So back to faq 1804:
The mentioned unitttest module is used like this (taking your example):

class UnitTestA(unittest.Testcase): # add
    def setUp(self):
        print "in Setup"
    def tearDown(self):
         print "in teardown"
    def test_empty(self):
        print "in test"
        return True

suite = unittest.TestLoader().loadTestsFromTestCase(UnitTestA) # add
unittest.TextTestRunner(verbosity=2).run(suite) # add

The 3 lines marked with #add are the test management frame, that is internally added by Sikuli.
Running this in the normal IDE run produces a textual printout of the test results.

The faq is meant for people, who want to organize a bunch of tests
efficiently and might want to get more readable/useable output.

So make your first steps using the IDE test feature, together with the
option to run the test scripts one after the other from command line
using the option -t.

These are the top oddities experienced:
-- import not supported as expected
-- tests performed in reverse order
-- IDE hangs when tests have syntax errors

BTW: if you want to do more complex things (it is very easy to get into
this very fast with Sikuli ;-), you need to have some basic knowledge of
Python scripting.

You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.