代码可测性度量工具Testability explorer

发表于:2010-1-25 12:44

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

 作者:liangjz    来源:51Testing软件测试博客

  执行maven目标分析代码可测性

  D:\project\morgan\trunk\member.service.china> mvn clean install

  D:\project\morgan\trunk\member.service.china>mvn com.google.testability-explorer:maven-testability-plugin:1.3.4-SNAPSHOT:testability

  或者看: http://code.google.com/p/testability-explorer/wiki/HowToMakeARelease

  在顶级工程上执行上述命令也可,但是site目录会仅生成在各个子工程目录下。

  结果如下:

Issues that cause the most untestable classes

Cost: 6,376

Classcom.alibaba.china.biz.dal.EncryptPtpis hard to test because:

It is expensive to construct an instance of the class, and every test will need to call a constructor.

These static initializers will need to be run once, when the class is loaded.Why is it bad?

On line 30,
 static void generateCipher(String)is declared
 contributing 20% of total class cost
 

Instead of initializing this state statically, try initializing a fresh copy in each instance. Creating new objects in Java is cheap, and this static state can't be cleaned up between tests.

Cost: 6,254

Classcom.alibaba.china.biz.common.security.BlowfishEncrypteris hard to test because:

It is expensive to construct an instance of the class, and every test will need to call a constructor.

These static initializers will need to be run once, when the class is loaded.Why is it bad?

On line 29,
 static BlowfishEncrypter()is declared
 contributing 20% of total class cost
 

Instead of initializing this state statically, try initializing a fresh copy in each instance. Creating new objects in Java is cheap, and this static state can't be cleaned up between tests.

Cost: 4,982

Classcom.alibaba.china.member.internal.security.Authenticationis hard to test because:

It is expensive to construct an instance of the class, and every test will need to call a constructor

(以上言论仅代表作者的个人观点,不代表51Testing观点)

版权声明:本文出自liangjz的51Testing软件测试博客:http://www.51testing.com/?13997

原创作品,转载时请务必以超链接形式标明本文原始出处、作者信息和本声明,否则将追究法律责任。

33/3<123
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

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

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

沪ICP备05003035号

沪公网安备 31010102002173号