← Back to team overview

sikuli-driver team mailing list archive

[Question #100436]: Running tests using Python's unittest --- to be adapted to version X-1.0

 

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

Description changed to:
**** Take care **** For people who read through this really impressive
and helpful thread:

It starts based on version 0.9x and ended with version 0.10.1

While the basics concerning Python unittest are still valid, things
regarding the Sikuli features, usage and environment have to be checked,
when working with Sikuli X-1.0.

***************************************************************  
The following method works on Mac and Windows. 

1) Write a real unit test using PyUnit.

import sys
import unittest
# setAutoWaitTimeout(5000) # till version 0.9x
setAutoWaitTimeout(5) # beginning with version 10.x and for X-1.0

class MyTests(unittest.TestCase):
   def setUp(self):
      switchApp("/Applications/Safari.app")
      # @todo: do similar for IE on Windows

   def tearDown(self):
      pass

   def testNewTab(self):
      type("t", KEY_META)
      type("https://answers.launchpad.net/sikuli/+question/99979\n";)
      m = find("sikuli-logo.png")
      assert(m is not None and m.getScore() > 0.9)

suite = unittest.TestLoader().loadTestsFromTestCase(MyTests)
unittest.TextTestRunner(verbosity=2).run(suite)

2) Save your unit test as a Python script in a folder with a matching
name and .sikuli suffix (e.g., mytest.sikuli/mytest.py).

3) Download the cross-platform, command line tool version of Sikuli from
http://groups.csail.mit.edu/uid/sikuli/download.shtml.

4) Extract the contents of the command line tool zip.

On Windows:

4) Download the Windows IDE version of Sikuli.

5) Extract the Lib/ folder from the sikuli-ide-full.jar.

6) Move the Lib/ folder into the same directory as the sikuli-script.jar
from the command line tool version of Sikuli.

7) Execute your test script like so (assuming cygwin):

export PATH=$PATH:./win32
java -Dpython.path=Lib/ -jar sikuli-script.jar mytest.sikuli 2> test-output.log

8) The test-output.log contains the results of the unit test run while
stdout shows the sikuli logging info.


On Mac:

4) Download the Mac IDE version of Sikuli.

5) Extract the Lib/ folder from the Sikuli.app/Contents/Resources/Java
/sikuli-script.jar.

6) Move the Lib/ folder into the same directory as the sikuli-script.jar
from the command line tool version of Sikuli.

7) Execute your test script like so:

java -d32 -Dpython.path=Lib/ -jar sikuli-script.jar mytest.sikuli 2>
test-output.log

8) The test-output.log contains the results of the unit test run while
stdout shows the sikuli logging info.

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