Google Unit Test Confusion

半腔热情 提交于 2019-12-02 10:03:59

"All the documentation leads me to believe that I must create a Test Project. REALLY?"

Yes with c++ you have to, because there's no generic test runner executable artifact, as it's kind of provided with JUnit.

Can I create a subfolder in my project with all my unit tests, such that they will execute with each build?

I would recommend to put all the test case classes (as plain .cpp sources) into a separate project, and link with the classes under test from a separate library project. Include gtest_all.cc with the main() function, or link against the gtest library, with the test project.

To run the test cases add running the UnitTester artifact build from that project as an additional build step.


"Maybe the documentation just keeps mentioning creating a project and doesn't make it clear that the test code can be in your application project."

Well, that depends a lot upon your actual IDE/build system what is a single project (I prefer to use this term for single artifacts as a result), and a solution (or workspace) for a related collection of them.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!