java

位置:IT落伍者 >> java >> 浏览文章

检测代码是否有Junit Test Class的小功能[2]


发布日期:2019年05月03日
 
检测代码是否有Junit Test Class的小功能[2]

BTW:不要忘记将后面download的jar导过来

结果会打在Console里象这样

Loading netblogjavaxmpCVSClass

Loaded netblogjavaxmpCVSClass

Found java source file in C:\Documents and Settings\hut\workspace\AccountMethodLocation / net / blogjava / xmp / CVSClassjava

Parsing netblogjavaxmpCVSClass

Parsed a common class and brackets can matched the methods correctly

MethodParseEngine have searched methods(Including constructors)

Completed :Spend seconds to parse this file

[ public CVSClass(String) locate between and

public CVSMethod[] getCvsMethodArray() locate between and

public CVSConstructor[] getCvsConstructorArray() locate between and

public Set getMethodSet() locate between and

public Set getConstructorSet() locate between and

public String getClasspath() locate between and

public List getMethodList() locate between and

public String getClassName() locate between and

public boolean equals(Object) locate between and

public int hashCode() locate between and

]

我是怎么做的

用java反射拿出所有的的类的构造函数和方法

读java源文件通过匹配左右括号来匹配方法并记录出合适的位置

存在的问题

到目前为止这个小程序至少不能分析它自己的主类CVSParseMethod(很多Exceptions) 因为这个类里面定义的一些String中含用 { }而导致匹配的时候出错呵呵但是我保证它应该在>%的概率下正常工作

[] []

               

上一篇:开源技术:JUnit常用断言方法

下一篇:检测代码是否有Junit Test Class的小功能[1]