Run some test cases usin unit test

Asked by Ezequiel

Hi all,
How can I add a couple of sikuli test cases using unit test??

My idea is call 3 or 4 test cases and run them together. Not write all the code inside, only make a type of calls.

Do I have a way to do it? It is clear?

Thanks in advance.

Question information

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

- talking about Sikuli IDE's unit test feature?

trying an answer:

- a testcase is coded in a def()
- the test case is run calling the def()
- the def()'s might be packed together in a modul that is loaded to execute the def()'s

e.g. principally

*** module tests.sikuli

def test1():
     print "test1"

def test2():
     print "test2"

def test3():
     print "test3"

*** script runtests.sikuli in same folder

from tests import *

test1()
test2()
test3()

When you want to use the unit test feature, you have to do a bit more.

Revision history for this message
Ezequiel (pollakezequiel) said :
#2

Hi RaiMan,

I tried this and works:

*****tests.sikuli****

def test1(self):
     print "test1"

def test2(self):
     print "test2"

def test3(self):
     print "test3"

Now, related to your answer how can I call them with other script?:
Must I use this??

myScriptPath ="C:\\xxx\\xxx\\Desktop\\SIKULI TCs\\FOLDER"
if not myScriptPath in sys.path: sys.path.append(myScriptPath)
import tests

test.test1()
test.test2()
.......

Thanks

Revision history for this message
Ezequiel (pollakezequiel) said :
#3

I wrote a comment up.

Revision history for this message
Ezequiel (pollakezequiel) said :
#4

When I run unit test from ide, I must arrange the test cases inverted.
Example:
If I want to run test 1, test 2 and test 3, Sikuli runs the test3 first, then test2 and test 1 at last.

Is that ok?? why sikuli does that?

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

ok, you seem to have some basic knowledge.

This and your questions let me say: forget IDE's unit test feature in its current shape.
Use Pythons unittest module directly.

see https://answers.launchpad.net/sikuli/+question/177536 comment #1 for some explanations.

The advantage:
with a little extra effort, you can run your scripts normally and have all options you have with normal Sikuli scripts.

Come back if you have questions after e.g. googling for "jython unittest".

Revision history for this message
Ezequiel (pollakezequiel) said :
#6

Thanks RaiMan, that solved my question.