软件质量保证与试——静态白盒测试.doc

  1. 1、本文档共5页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
软件质量保证与试——静态白盒测试

实验分数 占百分比 得分 实验室演示 10% 实验报告 90% 合计 100% 软件质量保证与测试 2015年春季 教师:杨秋辉 实验报告1– 静态白盒测试 学号: 姓名: 引言 白盒测试(white-box testing)又称透明盒测试(glass box testing)、结构测试(structural testing)等,软件测试的主要方法之一,也称结构测试、逻辑驱动测试或基于程序本身的测试。测试应用程序的内部结构或运作,而不是测试应用程序的功能(即黑盒测试)。在白盒测试时,以编程语言的角度来设计测试案例。测试者输入数据验证数据流在程序中的流动路径,并确定适当的输出,类似测试电路中的节点。测试者了解待测试程序的内部结构、算法等信息,这是从程序设计者的角度对程序进行的测试。 FindBugs是由Bill Pugh和David Hovemeyer创建的开源程序,用来查找Java代码中的程序错误。它使用静态分析来识别Java程序中上百种不同类型的潜在错误。潜在错误可分为四个等级:恐怖的(scariest)、吓人的(scary)、令人困扰的(troubling)和值得关注的(of concern),这是根据其可能产生的影响或严重程度,而对开发者的提示。 测试结果记录 表1 FindBugs静态测试结果分析表 编号 源代码(指明是哪个函数中的哪几条语句) 编译提示 静态测试结果 你的修改 再次静态测试结果 你的理解 1 函数function1(): if(str!=null) 无错误 Bug: Repeated conditional test in test.function1() The code contains a conditional test is performed twice, one right after the other (e.g., x == 0 || x == 0). Perhaps the second occurrence is intended to be something else (e.g., x == 0 || y == 0). 删除第2个 if(str!=null) 无错误 是缺陷,需要根据程序实际应该的逻辑来确定是否修复。 如静态测试结果所述,两个相同的条件语句重复出现,没有实际意义。如果只是程序员无意中多写了一次,不会影响程序运行结果;但按照代码编写的一般规律,这里应该是两个不同的判定条件。 2 函数function3(): String str3 = String.format({0}{1}, str1, str2); 无错误 Bug: String.format(String, Object[]) needs printf-style format but called with MessageFormat A method is called that expects a Java printf format string and a list of arguments. However, the format string doesnt contain any format specifiers (e.g., %s) but does contain message format elements (e.g., {0}). It is likely that the code is supplying a MessageFormat string when a printf-style format string is required. At runtime, all of the arguments will be ignored and the format string will be returned exactly as provided without any formatting. 修改为String str3 = String.format(%s%s, str1, str2); 无错误 是缺陷,函数调用时参数使用错误。 String.format(String, Object[])前面的String部分需要像printf一样使用%s占位符才能显示后面的变量。 3 函数function5(): return new Random(seed).nextInt(); 无错误 Bug: Random object created and used only once in Test.function5(int) This code creates a java.util.Ra

文档评论(0)

jiqinyu2015 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档