Confused about the Unit Test feature in Sikuli

Asked by Henk Noppe

The past days I have been trying to rebuild my test so that I can use the Unit test feature in Sikuli, but I cannot get it to work. I rebuild my code as below.

def setUp(self):
    OmnisApp = App("/Applications/Omnis Studio 5.0.1 RT.app")
    OmnisApp.focus()
    wait(1)

def testAfspraakInvoeren(self):
    click("MainMenuExtra-1.png")
    click("MainMenuExtra_Agenda-2.png")
    wait(1)
    click(Pattern("Tijd.png").similar(0.99))
    click("GemaakteAfspraak-1.png")
    type("56")
    click("GroenVinkje.png")
    assert exists("GemaakteAfspraak.png")

After this I saved the file and opened the Unit Test (cmd+U). Then I click run. What happens next is that Sikuli interface shrinks to a small semi-transparent window (http://tinypic.com/r/2luxqhw/5) and futher nothing happens. In the small window I can click Run again, but still nothing happens. I have read the documentation about the Unit Test (http://sikuli.org/docx/faq/020-unit-test.html?highlight=unit%20test) and I tried those instruction, but it does not work. I also read the article on the link https://answers.launchpad.net/sikuli/+faq/1804. I suppose it is another way of running Sikuli unit test using python. I did not try this one yet, cause I first want to try the 'simple' one.

How should I use the Unit Test in Sikuli it self? Or should I go for the Python version?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Henk Noppe
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

As long as your tests are such simple (click and wait ;-) and do not need any special features (calling other functions, or even imports) you can start with the IDE feature. But usually, fun with it does not last very long.

IDE's unit test run usually hangs, if there are some syntax errors in the script (e.g. indentation problems, missing colons, mismatched brackets, ...). If the run hangs, try to use the abort key (shift-cmd-c on Mac) and have a look at the message area.

If unsure, I just "run" the script in normal mode, which does nothing, since it only contains def()'s, that are not called. But at least most syntax problems are detected. Then you can switch back using cmd-u and run it in test mode.

Always remember to save the script again if you make any changes.

Revision history for this message
Henk Noppe (henk-n) said :
#2

Thanks again. The abort key is very handy. With this I discovered that the Unit test can not handle long path names or path/file names with spaces. eg. /Users/Henk/Documents/OmniHis/Local Repositories/Scipio/Sikuli TestScripts/Agenda/4756 Afspraken_tekst invoeren/Mac

I moved the script to the desktop, but still I got a message which indicated that the script was pointing to the old path. I rewrote te script and that problem was gone. Now I have another one which is that when I click the button run it does nothing but showing the text below in the 'Message' pain.
Running...
Finished: 0 seconds

I am using the same script as above. Even when I only have the setUp method in it and saved the file after that. I still get this message when I runned the saved file. Close and restarted Sikuli without any effect.

Also I runned the script from the terminal, but got more or less the same result. (see below)
/Applications/Sikuli-IDE.app/sikuli-ide.sh -r /Users/Henk/Desktop/Mac/TestScript.sikuli/
[info] Sikuli vision engine loaded.
[info] Mac OS X utilities loaded.
[info] VDictProxy loaded.

What Am I doing wrong?

PS: I also stumbled on the sort of bug. When I close Sikuli with some open files and I reopen Sikuli by double clicking on a file which was open in Sikuli when I closed it. Then The file is opened twice in Sikuli.

Revision history for this message
Henk Noppe (henk-n) said :
#3

I also got the same result with the script below.
def setUp(self):
    TextEditorApp = App("/Applications/TextEdit.app")
    TextEditorApp.focus()
    wait(1)

Revision history for this message
RaiMan (raimund-hocke) said :
#4

A script, that is built for the unit test feature of the IDE (def setUp(self), def tearDown(self) and some def testXYZ(self) ) has to be run from the command line using the -t parameter instead of -r

Have a look at faq 1804 (my recommendation for unit tests).

Revision history for this message
Henk Noppe (henk-n) said :
#5

Och yeah you are quite right. I did some futher experimenting and saw that I omitted the prefix 'test'. After adding this the testscript is working. Thank you very much again!