帮助! Sikuli单元测试无法运行

发布于 2024-09-02 02:35:09 字数 319 浏览 4 评论 0原文

我无法在 xp 窗口中运行任何单元测试?

IDE 可以正常运行。我在编辑器中编写了简单的示例单元测试脚本,如下所示:

def testHelloWorld(self):

  print("Hello World!")

但单元测试窗口中没有显示任何测试。单击“单元测试”窗格的“运行”按钮时,没有任何反应,并且 IDE 窗口消失,除了重新启动 IDE 之外没有其他方法可以返回到该窗口。

这个问题困扰了我好几天了,如果有人能帮我解决这个问题,那就太好了!

非常感谢。

珍妮特

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.

Janet

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤城病女 2024-09-09 02:35:10

要运行单元测试,您必须有一个setUp 方法、一个tearDown 方法以及一个或多个名称以“test”开头的测试方法。他们每个人都以自我为第一论点。

这是您可以使用的模型。这是 Windows 计算器的示例测试(未测试):

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

这是一个更完整的单元测试示例,但它是为 Sikuli 0.9 编写的,因此许多 Sikuli 方法(单击、查找等)与当前版本不同西库利。但单元测试方法都在那里(setUp、tearDown、test*):
http://sikuli.org/documentation.shtml#examples/TestJEdit.sikuli /TestJEdit.html

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文