实验2

2020-02-21 16:16

《软件测试大学教程》实验报告

指导教师:易禹 姓名 张蓉 学号 201350080105 班级 计算机13-01 实验题目 Findbugs 实验时间 2015.10.19 实验内容:

3.1 Findbugs各项属性的配置说明:

Run Findbugs automnaticaly:编译工程和文件的时候自动运行 Minimum priority to report: 根据bug的优先权级别报告bug。 Enable bug categories: bug种类。 Correctness: 正确性。 Performance: 性能。

Internationalization:国际化。

Mutithreaded correctness:多线程的正确性。 Style: 样式。

Malicious code vulnerability :恶意代码。

Select bug patterns to check for: bug的校验模式,Bug的校验模式的设置是确定哪一类问题我们应该作为bug报告给用户

3.2 运行findbugs

A、findbugs发现的问题一共有3类,如下所示

1,Bug: Should solver.Matrix.nextCombination return a zero length array rather than null?It is often a better design to return a length zero array rather than a null reference to indicate that there are no results (i.e., an empty list of results). This way, no explicit check for null is needed by clients of the method.On the other hand, using null to indicate \is no answer to this question\

译文:返回一个零长度数组而不是零,它通常是一个更好的设计返回一个零长度数组而不

是一个空引用(即表明,没有结果,一个空列表的结果)。这种方式,不需要显式检查null客户的方法。另一方面,使用零来表示“没有回答这个问题“可能是合适的。

2,Bug: solver.Matrix.nextCombination(boolean) concatenates strings

using + in a loop,The method seems to be building a String using concatenation in a loop. In each iteration, the String is converted to a StringBuffer/StringBuilder, appended to, and converted back to a String. This can lead to a cost quadratic in the number of iterations, as the growing string is recopied in each iteration.

译文:错误:使用连接字符串+一个循环,这个方法建立在一个循环中使用连接字符串。在

每个迭代中,字符串转换为StringBuffer / StringBuilder转换回一个字符串。这可能导致成本数量的二次迭代,在每个迭代字符串复制。

Bug: Invocation of toStringon combination in

solver.Matrix.main(String[]),The code invokes toString on an array, which will generate a fairly useless result such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable String that gives the contents of the array.

译文:在组合代码调用toString数组,这将产生一个相当无用的结果。考虑使用数组,toString将数组转换成一个可读的字符串数组的内容。

3

B,解决问题

1,将private类改成public类

2,将String 改为StringBuffer

3,对数组调用toString()方法,String[] arr = reader.readNext(); System.out.println(Arrays.asList(arr).toString());

3.3、测试指定程序

7,运行结果截图

8、缺陷发现及修正 没有bug


实验2.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:青藏进川藏出自驾游路书 - 图文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: