Help! Sikuli unit test cannot work

I was unable to execute any unit tests either in the xp window?

IDE functionality. I am writing a simple example unit test script in an editor as shown below:

def testHelloWorld (self):

  print("Hello World!")

      

but no test appears in the unit test window. When I click the Run button in the unit test panel, nothing happens and the IDE disappears and there is no way to return to it except to restart the IDE.

It stuck me for a few days, it would be problematic if anyone can help me solve this problem!

Many thanks.

Janet

+2


a source to share


1 answer


To run a unit test, you must have a setUp method, a tearDown method, and one or more test methods that start with "test". Each of them perceives itself as the first argument.

Here is a layout you can use. This is a sample test for a Windows calculator (not tested):



def setUp(self):
    setAutoWaitTimeout(10)
    openApp("C:\\Windows\\system32\calc.exe") # open windows calculator
    wait("CalculatorWindow.png") # wait for calculator window to appear

def test_calculator(self):
    with Region(find("CalculatorWindow.png")):
        click("1_Button.png")      # Click "1"
        click("Plus_Button.png")   # Click "+"
        click("2_Button.png")      # Click "2"
        click("Equals_Button.png") # Click "="
    type("c",KEY_CTRL)
    assert Env.getClipboard() == 3

def tearDown(self):
    closeApp("Calculator") # Matches text from the window title bar

      

Here's a more complete unit test example, but it was written for Sikuli 0.9, so many of Sikuli's methods (click, search, etc.) differ from the current version of Sikuli. But there are single test methods (setUp, tearDown, test *): http://sikuli.org/documentation.shtml#examples/TestJEdit.sikuli/TestJEdit.html

+5


a source







All Articles