I'm trying to start testing my Qt project with Google tests. I read Qt Docs, but there is only description, how to create and run tests, but not integrate. 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
. Then I call init_tests
from main
function. 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? I created branch for my tests, then merge it to 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. 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. 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 :
: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 )
Answer to question 3 : become obvious too.
Note : for that to work it supposes that what you do in subproject1 and subproject2 is accessible, i.e that those libs are either static and included in test_project.pro or dynamic lib with exported symbols.