← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #176537]: Organizing Sikuli scripts, that represent tests

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--- Q1:

I do not understand: should I Be able to run them from play button on
top - single test

One addition to Q1: 
Currently not really automatically - not in the moment you write click("Image-from-myimages.png"), because this does not trigger the replacement of the filename by the thumbnail.
If the import has once been processed in the IDE, you will see the thumbnails when the scripts using the images are reopened in the IDE. 
So if you really need to see the thumbnails in the IDE, you have to run a script once after starting the IDE, that only contains 
from myImages import *. All scripts referencing images by plain filenames from myImages.sikuli will show the thumbnails when they are opened afterwards.
For this inconvenience there is already a request bug for a "rework" button, that updates the script in the current tab, just as when it was reopened including sanitizing of indents and some other things.

--- Q2:
When you use Python unit test, the normal organization is to have many test clusters organized in unittest.TestCase classes, which might reside in modules (e.g. testcase1.sikuli).

example:

# testcase1.sikuli 
from myImages import *
# the shared images are referenced in the defs
class MyTestsA(unittest.TestCase):
      def testA1(self):
           pass
      def testA2(self):
           pass
class MyTestsB(unittest.TestCase):
      def testB1(self):
           pass
      def testB2(self):
           pass
# end of testcase1.sikuli 

and a runner script:

# runner.sikuli
import unittest
from testcase1 import *
suite = unittest.TestLoader().loadTestsFromTestCase(MyTestsA)
unittest.TextTestRunner(verbosity=2).run(suite)
# end of runner.sikuli

consult Pythons unittest docs to find out, how to select tests from a
test case when forming a suite and other options to control, which tests
are run.

BTW: unit tests are best run from command line, since then you can be sure, that you start from scratch. If you run from IDE, you have to make sure, that your changes in imported scripts are used, which normally requires to restart the IDE.
HowTo: edit in IDE and run from command line in parallel.

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