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

后端 未结 1 938
日久生厌
日久生厌 2021-01-14 13:25

I am trying to figure out how to run Google Test against my C++ project using CMake. So far I have created a project called Simple and a Google Test project called SimpleTe

相关标签:
1条回答
  • 2021-01-14 14:00

    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
    0 讨论(0)
提交回复
热议问题