关闭

codeblocks+Mingw下配置单元测试工具 google test

发表于:2013-11-15 11:30

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:JustDoIT    来源:51Testing软件测试网采编

  google test 是google的c++开源单元测试工具,chrome的开发团队就是使用它。
  Code::Blocks 12.11(MinGW 4.7.1) (Windows版)
  Google Test 1.7.0
  一 编译Google Test
  运行cmake-gui
  在弹出来的对话框中
  Where is the source code之后填写解压的gtest,例如:D:/software/gtest-1.7.0
  Where to build the binaries之后填写生成的工程路径,例如:D:/software/gtest-1.7.0/codeblocks-mingw
  (网上看到说要点击Configure,然后勾选gtest_disable_pthreads之后的复选框,再进行下面的操作,这一步我没有做也没问题)
  点击Configure
  然后点击Generate
  如此一来,cmake就在D:/software/gtest-1.7.0/codeblocks-mingw下会自动生成Code::Blocks的project文件。
  双击该project文件(cbp文件),然后build就行了。
  二 使用Google Test
  需要注意的是:
  既想用C++11的新特征,又想顺利编译Google Test,你得用命令行参数-std=gnu++11,而不是-std=c++11。
  用codeblocks新建一个工程
  右键project,选择Build options...
  清除Compiler settings > Compile Flags下与-std=有关的复选框
  点击选项卡Compiler settings > Other options,在对话框中填写-std=gnu++11
  (如果没有使用c++11新特性,上面两步可以省略)
  在Linker settings > Other linker options下填写-lgtest
  点击OK
  点击选项卡Search directories
  在Compiler子选项卡中Add一项,填写D:/software/gtest-1.7.0\include
  在Linker子选项卡中Add一项,填写D:/software/gtest-1.7.0\codeblocks-mingw
  点击OK
21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号