Google 在可执行文件或静态/动态库中进行测试?
Google 建议将 googletest 链接到可执行文件中,并通过命令行参数执行测试。
我曾使用过 C# 和 Java 单元测试框架,并且更喜欢测试运行程序跨多个库/组件持续执行测试。
- 拥有较大代码库(许多库)的人如何管理他们的谷歌测试?
- 您有多个可执行文件吗?你使用 shell 脚本等吗?
- 您如何处理测试结果?
Google recommends linking to googletest into a an executable, and executing the tests via command line arguments.
I have worked with C# and Java unit testing frameworks and prefer test runners continuously executing the tests across multiple libraries/components.
- How do folks with larger code bases (many libraries) manage their googletests?
- Do you have multiple executables? Do you use a shell scripts etc?
- And how do you work with the test results?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我们的项目中,我们对某些特定模块(大约 60 个模块)进行了数百个单元测试,并且我们正在使用 googletest。为了避免项目的 bin 目录中有太多可执行文件,我们编译了单元测试而不链接它们。我们还为每个单元测试文件创建了 *.unit_dep 文件,在其中指定链接器的所有依赖项。
最后,我们编写了一个简单的程序,它打开这些unit_dep文件,在运行时将我们的单元测试编译到共享库中,然后通过dlopen()动态加载这些库,并通过调用googletest库的main()函数来执行。测试完成后,我们删除所有临时 *.so 文件。
好处是我们只有一个可执行文件来运行所有测试。付出的代价是创建共享库的一些开销时间。
In our project we have hundreds of unit tests for some specific modules (around 60 modules) and we are using googletest. To avoid having so many executable files in our project's bin directory we compiled our unit tests without linking them. We also created *.unit_dep files for every unit test file in which we specify all dependencies for the linker.
At the end we wrote a simple program which opens those unit_dep files, during runtime compiles our unit tests into shared libraries, then dynamically load those libs via dlopen() and executed by invoking the main() function of the googletest library. After the tests finish we delete all temporary *.so files.
The benefit is that we have only one executable which which runs all the tests. The price to pay is some overhead time for shared libraries creation.