GoogleTest.cmake 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. project(test_include_dirs)
  2. include(CTest)
  3. include(GoogleTest)
  4. enable_testing()
  5. add_executable(fake_gtest fake_gtest.cpp)
  6. gtest_discover_tests(
  7. fake_gtest
  8. TEST_PREFIX TEST:
  9. TEST_SUFFIX !1
  10. EXTRA_ARGS how now "\"brown\" cow"
  11. PROPERTIES LABELS TEST1
  12. )
  13. gtest_discover_tests(
  14. fake_gtest
  15. TEST_PREFIX TEST:
  16. TEST_SUFFIX !2
  17. EXTRA_ARGS how now "\"brown\" cow"
  18. PROPERTIES LABELS TEST2
  19. )
  20. add_executable(no_tests_defined no_tests_defined.cpp)
  21. gtest_discover_tests(
  22. no_tests_defined
  23. )
  24. # Note change in behavior of TIMEOUT keyword in 3.10.3
  25. # where it was renamed to DISCOVERY_TIMEOUT to prevent it
  26. # from shadowing the TIMEOUT test property. Verify the
  27. # 3.10.3 and later behavior, old behavior added in 3.10.1
  28. # is not supported.
  29. add_executable(property_timeout_test timeout_test.cpp)
  30. target_compile_definitions(property_timeout_test PRIVATE sleepSec=10)
  31. gtest_discover_tests(
  32. property_timeout_test
  33. TEST_PREFIX property_
  34. TEST_SUFFIX _no_discovery
  35. PROPERTIES TIMEOUT 2
  36. )
  37. gtest_discover_tests(
  38. property_timeout_test
  39. TEST_PREFIX property_
  40. TEST_SUFFIX _with_discovery
  41. DISCOVERY_TIMEOUT 20
  42. PROPERTIES TIMEOUT 2
  43. )
  44. add_executable(discovery_timeout_test timeout_test.cpp)
  45. target_compile_definitions(discovery_timeout_test PRIVATE discoverySleepSec=10)
  46. gtest_discover_tests(
  47. discovery_timeout_test
  48. TEST_PREFIX discovery_
  49. DISCOVERY_TIMEOUT 2
  50. )