QML 中 GUI 单元测试的意图

Intention of GUI-Unit Testing in QML

我对 Qt-Quick-Tests 进行了一些研究,尤其是 GUI-Unit Test。 我想知道意图是什么?是为了触发用 QML 编写的函数,还是我想查看 UI 的行为,或者它是完全不同的东西,我还没有提到?

I´d like to know what is the Intention?

猜测 Qt Test was written was to test Qt itself via regression testing. Qt has a continuous integration (CI) system that runs automated tests against batches of changes submitted by contributors through code review. You can see all of these tests in the tests directory of each Git repository. For example, here 的主要原因是 qtbase.git 的自动化测试。

从这些测试中,您会看到用户有多个应用程序,其中一些是:

  • Basic logic tests. For example, when I call foo(), I expect the bar() signal to be emitted。这并不特定于 GUI 应用程序,所有应用程序都可以从中受益。很多测试都属于这一类。
  • Render tests。通过比较屏幕上的图像 "grabbed" 检查用户界面是否正确呈现。
  • User interaction tests。如果我点击这个按钮,它会执行一些操作吗?如果我在此文本字段中键入内容,它会包含该文本吗?

这些是我刚刚编造的术语,尽管它们足够准确。如果您正在研究这个主题,您会在网上找到有关各种类型的自动化测试的资源。这不是 Qt 特有的。

Is it for triggering the functions that are written in QML

是的。

or do I want to see the behavior of the UI

它也可以测试。

请注意,某些应用程序太大或太复杂,无法通过 Qt 的库进行测试。 Squish 等产品可以为这些类型的应用程序自动进行 GUI 测试。