开发者

Help! Sikuli unit test can not run

I couldn't run any unit tests either in the window xp?

The IDE is functional. I write the simple example unit test script in the editor, as follow:

def testHelloWorld(self):

  print("Hello World!")

but no test shows up in the unit test window. When clicking the Run button of the Unit test pane, nothing happens, and the IDE window dissappears, there is no way to get back to it other than restarting the IDE.

It had stucked me for several days, that would be preciate if anyone can help me solve this problem!

Thank you very much.

J开发者_StackOverflow中文版anet


To run a unit test, you must have a setUp method, a tearDown method, and one or more test methods whose names begin with "test". Each of them takes self as their first argument.

Here is a mock-up you can use. It's an example test for the 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's title bar

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜