Is there a keyword driven approach to managing tests in Sikuli?

Asked by shaihulud

Is there a way to import created tests into another test? so you can make a large test suite out of smaller tests that tests certain functions.
This would be great to have a overview of larger tests and to easily create regression tests for newly developed features as part of the larger regression testing suite.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
obiwan-92
Solved:
Last query:
Last reply:
Revision history for this message
obiwan-92 (obiwan-92) said :
#1

Hello,

I think you will find your answer here : http://doc.sikuli.org/globals.html#importingsikuliscripts

Don't hesitate if you need more information. ;)

Regards.

Revision history for this message
shaihulud (cal-a) said :
#2

Great, thanks; thats a very big step in the right direction.
Unfortunately i don´t know Python....or much scripting for that matter so i´m not getting it to work :(

What I have done so far:
created two tests in the same directory. tests are called "open" and "close"
"open" opens a program and "close" closes it
Then i created a third test called "TestSuite" in which i hope to import and use the test cases "open" and "close".

I created a function in the test "open" and called it "ActionOpen" - it seems i should create a function in order to call it in the "TestSuite"?

In the test "TestSuite" i typed:
        myScriptPath = "C\\Users\\caan\\Documents\\SikuliModules"
        if not myScriptPath in sys.path: sys.path.append(myScriptPath)
        #im not sure why i typed the 2 lines above but seemed like I had to from the tutorial linked in your answer

        import open
        open.ActionOpen()

I feel like im fumbling in the dark so some pointers would be very helpful!
As I understand it its easier if the tests are in the same directory. But does that mean the folders for the test files need to be in the same directory or the testfiles themselves (script + pictures etc)?

Revision history for this message
obiwan-92 (obiwan-92) said :
#3

Hello,

Don't worry, there always a first time. =P
So far, every things you do, seem right, so it should be work.

For the explication (there many way to proceed, I will only explain one, for now) :
 - You create the script sikuli you want to call (open.sikuli in your example)
 - Then, in this script, you add some function (actionOpen and actionClose)
 - Now, you create a main script (TestSuite.sikuli)
 - you save it in the same directory than open.sikuli (not in open.sikuli itself)
 - In this main script you add the import open

 -> It will execute the open.sikuli script, since we have only two function we haven't call yet, it's do nothing.

After this line and still in the main script, we call our two function like this :
open.actionOpen()
open.actionClose()

It's that more clear ?
Regards.

Revision history for this message
shaihulud (cal-a) said :
#4

Thats strange, so it should work. Im getting a error when runnint the TestSuite:
[error] script [ TestSuite ] stopped with error in line 2
[error] NameError ( global name 'click' is not defined )

Heres images of what ive done:
http://postimg.org/image/8ezzthpnp/
http://postimg.org/image/ifjn6a31v/
http://postimg.org/image/txdz109sd/

Revision history for this message
Best obiwan-92 (obiwan-92) said :
#5

Ah yes.

Specifically for Sikuli, you have to add the line :
from sikuli import *
in the open.sikuli script.

Have a nice day.

Revision history for this message
shaihulud (cal-a) said :
#6

Great thanks alot for your help, its working now :) Have a extra good day to you!

Revision history for this message
shaihulud (cal-a) said :
#7

Thanks obiwan-92, that solved my question.