Google Test separate project - How to get tests running against the C++ project

浪子不回头ぞ 提交于 2019-12-01 10:33:28

The problem seems to be the organization of your code modules. Supposed you have a c++ target project, that provides an executable program as it's final output:

  • I suppose you want to create two executable artifacts
    • your final application
    • a test runner application that runs all test cases you have specified
  • As for this should be your misconception, how to setup this scenario properly:
    You cannot link functions from an executable artifact (the application) into another one (the test runner).
  • You can either
    • provide the core classes separate in a library and link it to your final application and the test runner. The application should provide a thin wrapper from the main() entry point.
    • add links to the sources for the classes under test, and completely compile them in the test runner environment
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!