# Google Test Integration With Xcode
This project demonstrates two ways to integrate the Google Test C++ unit testing library with Xcode:
## Standalone Executable
This is the more typical setup seen when using Google Test, but does not provide integration with Xcode's unit testing UI. It is illustrated by the "standalone" target. The Google Test library can either be built separately as a framework or as a static library as shown in this project. The framework or static library is linked to a command line tool that includes all unit tests, and when this tool is run typical Google Test output is generated.
To run tests as part of an Xcode build and get inline reporting of failures add a run script phase that executes the tool from it's built location. The standalone target demonstrates this, when built the tool will execute as part of the build and any test failures will be highlighted inline in code and appear in the issue navigator.
To debug a failing test in a configuration like this you can temporarily disable execution of the test runner as part of the build by expanding the script phase and enabling the "Run script only when installing" option.
## Unit Test Bundle
The "TestBundle" and "TestBundle-iOS" targets define Xcode unit test bundles that can run both Google Test and Objective-C test cases. They allow for simple execution of C++ tests in iOS apps and running both C++ and Objective-C tests through a single test runner. They also integrate with Xcode's unit test running and reporting capabilties.
As with the standalone tool, the test bundle links the Google Test library and includes all unit tests. To run it, select the "demo" or "demo-ios" static library as the active target and execute its test action. Test results will appear in the build log and test navigator, and tests can be debugged as usual. Tests can also be run individually by right-clicking on the test or test case in the test navigator and selecting the "Test" action. Once run with this filter the "Test Again" command will also work to run just the selected test(s).
Because Xcode displays only a single line of failed test output in its interface, you may need to view the build log and expand the output for the failed test case to see all relevant Google Test output for test failures.
Note that test bundles can be passed distinct command line arguments so Google Test can be controlled via the usual --gtest arguments. To do this edit the scheme for the "demo" target, select the Test action, then the Arguments tab. Here you can uncheck the "Use the Run action's arguments and environment variables" option and specify the --gtest options to control Google Test's behavior.
没有合适的资源?快使用搜索试试~ 我知道了~
xcode-googletest:谷歌测试与 Xcode 的集成
共193个文件
cc:71个
h:32个
py:19个
需积分: 13 1 下载量 10 浏览量
2021-05-31
10:10:50
上传
评论
收藏 1.13MB ZIP 举报
温馨提示
谷歌测试与 Xcode 集成 该项目演示了两种将 Google Test C++ 单元测试库与 Xcode 集成的方法: 独立的可执行文件 这是使用 Google Test 时看到的更典型的设置,但不提供与 Xcode 的单元测试 UI 的集成。 它由“独立”目标说明。 Google Test 库既可以作为框架单独构建,也可以作为静态库构建,如本项目所示。 框架或静态库链接到包含所有单元测试的命令行工具,并且在运行此工具时会生成典型的 Google 测试输出。 要将测试作为Xcode构建的一部分运行并获得故障的内联报告,请添加一个运行脚本阶段,该阶段从其构建位置执行该工具。 独立目标演示了这一点,构建时该工具将作为构建的一部分执行,任何测试失败都将在代码中内嵌突出显示并出现在问题导航器中。 要在这样的配置中调试失败的测试,您可以通过扩展脚本阶段并启用“仅在安装时运行脚本”选项来暂时禁用
资源详情
资源评论
资源推荐
收起资源包目录
xcode-googletest:谷歌测试与 Xcode 的集成 (193个子文件)
configure.ac 3KB
Makefile.am 10KB
gtest.cbproj 10KB
gtest_unittest.cbproj 8KB
gtest_main.cbproj 8KB
gtest-all.cc 346KB
gtest_unittest.cc 234KB
gtest.cc 180KB
gtest_pred_impl_unittest.cc 76KB
gtest-death-test.cc 50KB
gtest-printers_test.cc 48KB
gtest-death-test_test.cc 42KB
gtest-port_test.cc 38KB
gtest-param-test_test.cc 33KB
gtest_output_test_.cc 32KB
gtest-port.cc 27KB
gtest-filepath_test.cc 23KB
gtest-filepath.cc 14KB
gtest-unittest-api_test.cc 13KB
gtest-printers.cc 12KB
gtest-typed-test_test.cc 11KB
gtest-listener_test.cc 10KB
gtest_stress_test.cc 9KB
gtest-tuple_test.cc 9KB
sample6_unittest.cc 9KB
gtest_catch_exceptions_test_.cc 9KB
gtest_repeat_test.cc 8KB
gtest-options_test.cc 8KB
gtest-test-part_test.cc 7KB
sample8_unittest.cc 7KB
gtest_environment_test.cc 6KB
sample5_unittest.cc 6KB
gtest_xml_output_unittest_.cc 6KB
sample9_unittest.cc 6KB
sample3_unittest.cc 5KB
gtest-message_test.cc 5KB
sample1_unittest.cc 5KB
sample7_unittest.cc 5KB
sample10_unittest.cc 5KB
gtest_premature_exit_test.cc 5KB
gtest_list_tests_unittest_.cc 5KB
gtest-test-part.cc 4KB
gtest-linked_ptr_test.cc 4KB
sample2_unittest.cc 4KB
gtest-typed-test.cc 4KB
gtest-death-test_ex_test.cc 4KB
gtest_env_var_test_.cc 3KB
gtest_filter_unittest_.cc 3KB
gtest_throw_on_failure_ex_test.cc 3KB
gtest_shuffle_test_.cc 3KB
gtest_break_on_failure_unittest_.cc 3KB
gtest_throw_on_failure_test_.cc 3KB
gtest_color_test_.cc 3KB
gtest-param-test2_test.cc 3KB
widget_test.cc 3KB
sample1.cc 2KB
gtest_no_test_unittest.cc 2KB
widget.cc 2KB
sample2.cc 2KB
gtest_all_test.cc 2KB
gtest_sole_header_test.cc 2KB
gtest_prod_test.cc 2KB
gtest-all.cc 2KB
gtest_help_test_.cc 2KB
gtest-typed-test2_test.cc 2KB
gtest_xml_outfile2_test_.cc 2KB
gtest_xml_outfile1_test_.cc 2KB
gtest_link.cc 2KB
sample4.cc 2KB
gtest_uninitialized_test_.cc 2KB
sample4_unittest.cc 2KB
gtest_main_unittest.cc 2KB
gtest_all.cc 2KB
gtest_main.cc 2KB
gtest_main.cc 2KB
production.cc 2KB
CHANGES 6KB
internal_utils.cmake 9KB
configure 551KB
CONTRIBUTORS 1KB
CounterTest.cpp 306B
main.cpp 133B
Counter.cpp 111B
depcomp 20KB
.gitignore 24B
gtest.groupproj 2KB
config.guess 44KB
gtest.h 811KB
gtest-param-util-generated.h 188KB
gtest-type-util.h 181KB
gtest.h 86KB
gtest-param-test.h 74KB
gtest-port.h 67KB
gtest-internal-inl.h 45KB
gtest-internal.h 43KB
gtest-printers.h 31KB
gtest-tuple.h 28KB
gtest-param-util.h 24KB
gtest_pred_impl.h 15KB
gtest-death-test-internal.h 13KB
共 193 条
- 1
- 2
moseswangbp981
- 粉丝: 26
- 资源: 4639
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0