[英]Qt C++ Integration tests (webcam, db)
I am developing an app in Qt, which uses webcam and then saves some summary data into the database. 我正在Qt中开发一个应用程序,该应用程序使用网络摄像头,然后将一些摘要数据保存到数据库中。 I am using Qt except 3rd party library which is used to capture images from webcam and generate needed data. 我正在使用Qt,除了第三方库(用于从网络摄像头捕获图像并生成所需数据)之外。
Question is how can I implement integration tests with QTest? 问题是如何使用QTest实施集成测试?
I mean basically, to be sure, that everything works I need to: 基本上,我的意思是确保一切正常,我需要:
So answering my own question: I should use some mocking library like google mock. 所以回答我自己的问题:我应该使用一些模拟库,例如google模拟。 This way I can mock my class for gathering images from camera and call callbacks with captured images. 这样,我可以模拟我的类以从相机收集图像,并使用捕获的图像调用回调。 I can do the same thing for db access and just verify, that proper inserts were generated. 对于数据库访问,我可以做同样的事情,只是验证是否已生成正确的插入。
Then it comes another question - how can I provide mocks to my application instead of real classes when executing a test? 接下来是另一个问题-执行测试时,如何为我的应用程序提供模拟,而不是实际类? Should I make an interface for them and then provide as constructor arguments to the QWindow? 我应该为它们创建一个接口,然后将其作为构造函数参数提供给QWindow吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.