[英]Including google tests in Qt project
I'm trying to start testing my Qt project with Google tests. 我正试图用Google测试开始测试我的Qt项目。 I read Qt Docs , but there is only description, how to create and run tests, but not integrate.
我读过Qt Docs ,但只有描述,如何创建和运行测试,但没有集成。 So I had some questions.
所以我有一些问题。
Now I store test project this way: 现在我以这种方式存储测试项目:
project.pro
|
--- subproject1.pri
|
--- subproject2.pri
|
| ...
|
--- test_project.pri
|
--- init_tests.cpp
Is that correct way to place tests? 这是测试的正确方法吗?
::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS();
Now I run it from init_tests.cpp
. 现在我从
init_tests.cpp
运行它。 Then I call init_tests
from main
function. 然后我从
main
函数调用init_tests
。 It seems wrong, but I don't know another way to do this. 这似乎不对,但我不知道另一种方法。
So if I use previously described way to integrate tests, how can I remove it from deployment? 因此,如果我使用先前描述的方法来集成测试,我该如何从部署中删除它?
Where should I place tests in git repo? 我应该在git repo中放置哪些测试? I created branch for my tests, then merge it to master.
我为我的测试创建了分支,然后将其合并到master。 Is that correct?
那是对的吗?
Thanks for answers, sorry for my broken English. 谢谢你的回答,抱歉我的英语不好。
Answer to question 4 : that seems correct for the first implementation, but then this branch must die, you don't want to have a branch with the test. 对问题4的回答:对于第一个实现似乎是正确的,但是这个分支必须死掉,你不想在测试中有一个分支。 Commit made on any branches must included related Unit Test and must be pushed only when tests are green...
在任何分支上进行的提交必须包含相关的单元测试,并且只有在测试为绿色时才必须推送...
Answer to question 1/2 : Your tests should be in a standalone executable that should not be shipped to your client.. Normally you have one pro file per executable target. 回答问题1/2:您的测试应该是一个独立的可执行文件,不应该发送到您的客户端。通常,每个可执行目标都有一个专业文件。 So I would rather do :
所以我宁愿这样做:
project.pro
|
--- subproject1.pri
|
--- subproject2.pri
|
| ...
|
test_project.pro
--- test_project.pri
|
--- main.cpp
With main.cpp holding your lines : 随着main.cpp保持你的行:
:testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
.. suddently it becomes obvious , don't you think ? 突然间它变得明显,你不觉得吗?
(and of course only test_project.pro contains include and reference to Google Test ) (当然只有test_project.pro包含对Google Test的包含和引用)
Answer to question 3 : become obvious too. 对问题3的回答:也变得明显。
Note : for that to work it supposes that what you do in subproject1 and subproject2 is accessible, ie that those libs are either static and included in test_project.pro or dynamic lib with exported symbols. 注意:为了实现这一点,它假设你在subproject1和subproject2中所做的是可访问的,即那些lib是静态的并包含在test_project.pro中或包含导出符号的动态lib中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.