软件测试实验学习笔记系列5-单元覆盖测试

发表于:2013-8-08 11:01

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

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

  编译命令:gcc-o autosell -fprofile-arcs -ftest-coverage autosell.c

  执行程序(./autosell)随便输入一些测试用例:

  测试结果:

  显示总体覆盖率:gcov autosell.c
  File'autosell.c'
  Linesexecuted:94.55% of 55
  Creating'autosell.c.gcov'

  显示函数覆盖信息:gcov-f autosell.c
  Function'process'
  Linesexecuted:90.00% of 20
  Function'pushbutton'
  Linesexecuted:100.00% of 9
  Function'getcoin'
  Linesexecuted:100.00% of 9
  Function'nochange'
  Linesexecuted:75.00% of 4
  Function'welcome'
  Linesexecuted:100.00% of 4
  Function'main'
  Linesexecuted:100.00% of 9
  File'autosell.c'
  Linesexecuted:94.55% of 55
  Creating'autosell.c.gcov'

  显示分支信息:gcov-b autosell.c
  File'autosell.c'
  Linesexecuted:94.55% of 55
  Branchesexecuted:100.00% of 28
  Takenat least once:92.86% of 28
  Callsexecuted:87.50% of 24
  Creating'autosell.c.gcov'

  具体的autosell.c.gcov信息自行查看

  参考资料:

  [1]软件测试实验指导教程/蔡建平, 清华大学出版社, 2009.11

  [2]软件测试学习:测试覆盖率工具EclEmma安装与使用:http://liangruijun.blog.51cto.com/3061169/803473

  [3]使用Eclemma进行覆盖测试:http://www.ibm.com/developerworks/cn/java/j-lo-eclemma/

相关文章:

软件测试实验学习笔记系列4--CppUnit

软件测试实验学习笔记系列6--图形界面测试(GUI)

44/4<1234
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

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

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

沪ICP备05003035号

沪公网安备 31010102002173号