Get test a to run before test b

Asked by Paul Lovewell

Hey folks. I'm sure this is pretty dumb question. I've written a huge Sikuli tour through a complex part of my app and it is tight. However I'm starting to port over to Unit test running and have hit a snag that just trips me up: Order-of-operation of the tests. Here is example for my app:

def test1_Launch(self):
    with Region(find("image.png")):
        click("image.png") # Launch HD
        wait(2)
        assert exists("image.png") # StartPanel exists, launch successful.

def test2_EnterEmail(self):
    with Region(find("image.png")):
        click("image.png") # Click Email.
        wait(1)
        assert exists("image.png") # Keyboard invoked.

That's how it appears in Sikuli IDE. But no matter what I do (I've whittled it down, removed my setUp and tearDown trying to get this to go) it always wants to run test2 before test1. I can paste test 2 over test 1 and it still runs test 2 before test 1. I've checked and double-checked the Stupids like saving before each change, Run instead of Play, all that kind of thing that trips up new unit-scripters with the IDE and it just always wants to run test2 before test1. Overall, I'm looking at a script that will run ~300 defined cases and they're ready to go once I can solve whatever dumb thing I'm doing here....HELP!

Question information

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

This is one of the weirds of this Sikuli IDE feature.

the tests are just run backwards in the sequence they are written: the last one first, the first one last. And the def names do not matter at all - they only have to start with test. Only the physical sequence matters.

so just rearrange your test def.'s.

def test2_EnterEmail(self):
    with Region(find("image.png")):
        click("image.png") # Click Email.
        wait(1)
        assert exists("image.png") # Keyboard invoked.

def test1_Launch(self):
    with Region(find("image.png")):
        click("image.png") # Launch HD
        wait(2)
        assert exists("image.png") # StartPanel exists, launch successful.

BTW: If you want to be the master of the test environment, use the Python unit test yourself and run your tests from command line:
http://docs.python.org/library/unittest.html (or other sources in the net).

Revision history for this message
Bob Hag (bobhag) said :
#2

Is there a fix coming for fixing the Test Run Order?

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

@ Bob

Rewriting/optimizing the test feature is generally on the developer's todo-list. But currently I did not see any movement yet.

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

@ Bob

added your subscription

Revision history for this message
TestMechanic (ndinev) said :
#5

Currently the unit test run gets cases in backward alphabetic order :-)

Revision history for this message
Jerome Turner (jerome-xq) said :
#6

@RaiMan

[Quote]BTW: If you want to be the master of the test environment, use the Python unit test yourself and run your tests from command line:[/Quote]

What do you mean by this?

This example is already implementing unittest. Do you mean take this sikuli script and run it from commandline using -r -t and it should work fine. eg run the tests in order

or do you mean create a .py and import Sikuli some how, then run this from commandline??

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

@ Jerome
No, these kinds of tests that work in Sikuli IDE's test environment are not based on Pythons unittest. Internally they are run using Java's JUnit.

see faq 1804 for details

Can you help with this problem?

Provide an answer of your own, or ask Paul Lovewell for more information if necessary.

To post a message you must log in.