软件测试作业2
一、Checkstyle安装与使用
1.从http://sourceforge.net/projects/eclipse-cs/ 下载插件
2.下载后,把里面的两个文件夹plugins和 features下面的文件分别拷贝到eclipse目录下面对应的Myplugins目录下,新建一个checkstyle目录中,同时在eclipse根目录下的link文件夹中新建一个checkstyle.link
3.内容为如图所示,随后打开eclipse即可。
checkStyle 使用
1.选中工程,右键选择checkstyle->check code with checkstyle,检查错误即可以下是testforcheckstyle 工程的warning
Checkstyle的结果输出
序号 输出内容意义
1 Type is missing a javadoc commentClass 缺少类型说明
2“{” should be on the previous line “{” 应该位于前一行
3Methos is missing a javadoc comment方法前面缺少javadoc注释
4Expected @throws tag for “Exception”在注释中希望有@throws的说明
5“.” Is preceeded with whitespace “.” 前面不能有空格
6“.” Is followed by whitespace“.” 后面不能有空格
7“=” is not preceeded with whitespace“=” 前面缺少空格
8“=” is not followed with whitespace“=” 后面缺少空格
9“}” should be on the same line“}” 应该与下条语句位于同一行
10Unused @param tag for “unused”没有参数“unused”,不需注释
11Variable “CA” missing javadoc变量“CA”缺少javadoc注释
12Line longer than 80characters行长度超过80
13Line contains a tab character行含有”tab” 字符
14Redundant “Public” modifier冗余的“public” modifier
15Final modifier out of order with the JSL suggestionFinal modifier的顺序错误
16Avoid using the “.*” form of importImport格式避免使用“.*”
17Redundant import from the same package从同一个包中Import内容
18Unused import-java.util.listImport进来的java.util.list没有被使用
19Duplicate import to line 13重复Import同一个内容
20Import from illegal package从非法包中 Import内容
21“while” construct must use “{}”“while” 语句缺少“{}”
22Variable “sTest1” must be private and have accessor method变量“sTest1”应该是private的,并且有调用它的方法
23Variable “ABC” must match pattern “^[a-z][a-zA-Z0-9]*$”变量“ABC”不符合命名规则“^[a-z][a-zA-Z0-9]*$”
24“(” is followed by whitespace“(” 后面不能有空格 25“)” is proceeded by whitespace“)” 前面不能有空格
二、Findbugs安装与使用
1.去http://sourceforge.net/projects/findbugs/files/findbugs%20eclipse%20plugin/3.0.0/下载最新的findbugs 插件
2.下载下来的插件直接解压到eclipse目录下plugins目录下就行,该插件不能通过links方式进行安装。安装完毕即可看到
3.项目右键Findbug,我们也可以设置自动run findbugs,方便我们查错,以下为Finding bugs
二、Sourcemonitor安装与使用
1.百度下载包,下一步到底
2.检查checkstyle代码的结果,神器
posted on 2015-05-20 14:47 JungleKing 阅读(336) 评论(0) 收藏 举报