I heard Unit Testing is a great method to keep code working correctly.
我听说单元测试是保持代码正常工作的好方法。
The unit testing usually puts a simple input to a function, and check its simple output. But how do I test a UI?
单元测试通常将简单输入放入函数,并检查其简单输出。但是我该如何测试用户界面呢?
My program is written in PyQt. Should I choose PyUnit, or Qt's built-in QTest?
我的程序是用PyQt编写的。我应该选择PyUnit,还是Qt的内置QTest?
1 个解决方案
#1
17
There's a good tutorial about using Python's unit testing framework with QTest here.
这里有一个关于在QTest中使用Python单元测试框架的好教程。
It isn't about choosing one or the other. Instead, it's about using them together. The purpose of QTest is only to simulate keystrokes, mouse clicks, and mouse movement. Python's unit testing framework handles the rest (setup, teardown, launching tests, gathering results, etc.).
这不是关于选择其中一个。相反,它是关于将它们一起使用。 QTest的目的只是模拟击键,鼠标点击和鼠标移动。 Python的单元测试框架处理其余的(设置,拆卸,启动测试,收集结果等)。
#1
17
There's a good tutorial about using Python's unit testing framework with QTest here.
这里有一个关于在QTest中使用Python单元测试框架的好教程。
It isn't about choosing one or the other. Instead, it's about using them together. The purpose of QTest is only to simulate keystrokes, mouse clicks, and mouse movement. Python's unit testing framework handles the rest (setup, teardown, launching tests, gathering results, etc.).
这不是关于选择其中一个。相反,它是关于将它们一起使用。 QTest的目的只是模拟击键,鼠标点击和鼠标移动。 Python的单元测试框架处理其余的(设置,拆卸,启动测试,收集结果等)。