简体   繁体   English

Qt Creator IDE AutoTest插件

[英]Qt Creator IDE AutoTest plugin

In my current project I use QtTest for testing. 在我当前的项目中,我使用QtTest进行测试。 Till now I've added each test manually to main. 到目前为止,我已经将每个测试手动添加到main中。 This allowed me to display the results in Qt Creator's plugin AutoTest. 这使我可以在Qt Creator的插件AutoTest中显示结果。

I've tried to use some sort of test runner, which registers names of the classes and runs them automatically. 我尝试使用某种类型的测试运行程序,该程序注册类的名称并自动运行它们。

This approach works, however, I've lost the ability to view the tests in AutoTest view. 这种方法有效,但是,我已经失去了在AutoTest视图中查看测试的功能。 It allowed me to quicky spot the error as I have more than 40 test classes. 因为我有40多个测试类,所以它使我能够快速发现错误。

Could somebody explain why I don't see any output in AutoTest? 有人可以解释为什么我在AutoTest中看不到任何输出吗?

I've finally figured this out through minor hack. 我终于通过小技巧解决了这个问题。

To sum up: I have defined macro which registers all the tests and then in main I just call function will runs all these registered tests. 总结一下:我定义了注册所有测试的宏,然后在主菜单中,我只调用函数将运行所有这些注册的测试。

The issue is that they don't appear in AutoTest plugin in Qt Creator. 问题是它们没有出现在Qt Creator的AutoTest插件中。

Therefore I manually test one before running all the registered classes. 因此,我在运行所有已注册的类之前手动测试一个。 This way plugin allows me to collect the resuts of the test and I'm able to see also all my registered tests and later just comment the one test till I exit Qt Creator. 这样,插件可以让我收集测试的结果,而且我还可以查看所有注册的测试,然后只需评论一个测试,直到退出Qt Creator。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM