Qt应该使用什么单元测试框架? [英] What unit-testing framework should I use for Qt?

查看:298
本文介绍了Qt应该使用什么单元测试框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始一个需要一些跨平台GUI的新项目,我们选择了Qt作为GUI框架.

I am just starting up a new project that needs some cross-platform GUI, and we have chosen Qt as the GUI-framework.

我们也需要一个单元测试框架.直到大约一年前,我们为C ++项目使用了内部开发的单元测试框架,但现在我们正过渡到对新项目使用Google Test.

We need a unit-testing framework, too. Until about a year ago we used an in-house developed unit-testing framework for C++-projects, but we are now transitioning to using Google Test for new projects.

有人对使用Qt应用程序的Google Test有任何经验吗? QtTest/QTestLib是更好的选择吗?

Does anyone have any experience with using Google Test for Qt-applications? Is QtTest/QTestLib a better alternative?

我仍然不确定我们要在项目的非GUI部分中使用Qt多少-我们可能更愿意仅在核心代码中使用STL/Boost,并使用一个基于Qt的GUI的小接口

I am still not sure how much we want to use Qt in the non-GUI parts of the project - we would probably prefer to just use STL/Boost in the core-code with a small interface to the Qt-based GUI.

看起来很多人都倾向于QtTest.是否有任何将其与连续集成服务器集成的经验?另外,在我看来,每个新测试用例都必须处理单独的应用程序,这会引起很多麻烦.有什么好办法解决吗? Qt Creator是否具有处理此类测试用例的好方法,还是每个测试用例都需要一个项目?

It looks like many are leaning towards QtTest. Is there anybody who has any experience with integrating this with a continous integration server? Also, it would seem to me that having to handle a separate application for each new test case would cause a lot of friction. Is there any good way to solve that? Does Qt Creator have a good way of handling such test cases or would you need to have a project per test case?

推荐答案

我不知道QTestLib在这样一个笼统的术语中比另一个框架更好".它做得很好,这是测试基于Qt的应用程序的一种好方法.

I don't know that QTestLib is "better" than one framework for another in such general terms. There is one thing that it does well, and that's provide a good way to test Qt based applications.

您可以将QTest集成到新的基于Google Test的设置中.我还没有尝试过,但是基于QTestLib的架构,看来它不会太复杂.

You could integrate QTest into your new Google Test based setup. I haven't tried it, but based on how QTestLib is architected, it seems like it would not be too complicated.

使用纯QTestLib编写的测试具有-xml选项,您可以使用该选项以及一些XSLT转换,以转换为连续集成服务器所需的格式.但是,这很大程度上取决于您使用的CI服务器.我想同样适用于GTest.

Tests written with pure QTestLib have an -xml option that you could use, along with some XSLT transformations to convert to the needed format for a continuous integration server. However, a lot of that depends on which CI server you go with. I would imagine the same applies to GTest.

每个测试用例只有一个测试应用程序不会给我带来很多麻烦,但这取决于拥有一个可以很好地管理测试用例的构建和执行的构建系统.

A single test app per test case never caused a lot of friction for me, but that depends on having a build system that would do a decent job of managing the building and execution of the test cases.

我不知道Qt Creator中的每个测试用例都需要单独的项目,但是自从我上次查看Qt Creator以来,它可能已经改变了.

I don't know of anything in Qt Creator that would require a seperate project per test case but it could have changed since the last time I looked at Qt Creator.

我还建议您坚持使用QtCore并远离STL.在整个过程中使用QtCore将使处理需要Qt数据类型的GUI位更容易.在这种情况下,您不必担心从一种数据类型转换为另一种数据类型.

I would also suggest sticking with QtCore and staying away from the STL. Using QtCore throughout will make dealing with the GUI bits that require the Qt data types easier. You won't have to worry about converting from one data type to another in that case.

这篇关于Qt应该使用什么单元测试框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆