在使用ant+clover的时候,出现了如下异常:
BUILD FAILED
com.atlassian.clover.registry.NoSuchRegistryException: Clover registry file "/tmp/clover-db/ant-coverage.db" does not exist, cannot be read or is a directory.
Please ensure Clover has instrumented your source files.
You may need to remove existing .class files for this to occur.
at com.cenqua.clover.CloverDatabase.<init>(CloverDatabase.java:82)
at com.cenqua.clover.CloverDatabase.<init>(CloverDatabase.java:60)
at com.cenqua.clover.reporters.CloverReportConfig.getCoverageDatabase(CloverReportConfig.java:329)
at com.cenqua.clover.reporters.Current.getCoverageDatabase(Current.java:126)
at com.cenqua.clover.reporters.xml.XMLReporter.<init>(XMLReporter.java:52)
at com.cenqua.clover.reporters.CloverReporter.buildReporter(CloverReporter.java:70)
at com.cenqua.clover.tasks.CloverReportTask.generateReports(CloverReportTask.java:428)
at com.cenqua.clover.tasks.CloverReportTask.cloverExecute(CloverReportTask.java:385)
at com.cenqua.clover.tasks.CloverHtmlReportTask.cloverExecute(CloverHtmlReportTask.java:108)
at com.cenqua.clover.tasks.AbstractCloverTask.execute(AbstractCloverTask.java:55)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.Main.runBuild(Main.java:758)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Total time: 56 seconds
原因是没有生成clover的库文件。
解决的方法是:
ant with.clover build.clean build.compile junit.test cactus.test
需要重新编译生成clover库文件。
这样就生成库文件了。
ant clover.html
就可以生成报告了。
clover的使用,有一个非常重要的注意点:
The <clover-setup> task, must be called before compiling the sources. If the "with.clover" target is not called before "code" (compile) in the same invocation of Ant, the effect of clover-setup will lost. i.e. javac does not know to use the Clover compiler to instrument your source files before compiling them. It will not create the database and generate class file for clover use, hence clover will not take effect.
|----------------------------------------------------------------------------------------|
版权声明 版权所有 @zhyiwww
引用请注明来源 http://www.blogjava.net/zhyiwww
|----------------------------------------------------------------------------------------|
posted on 2010-12-01 08:55
zhyiwww 阅读(928)
评论(1) 编辑 收藏 所属分类:
j2ee 、
软件测试