Tomcat上的Cobertura

我正在尝试使用Cobertura应用代码覆盖率。 该应用程序部署在Tomcat 5中,但是当我检测.class文件时,应用程序停止工作。

这是我的步骤:

  • 编译应用程序(这在tomcat中运行)
  • 检测类文件。

    D:\test\cobertura-1.9.4.1\cobertura-instrument.bat --destination D:\test\instrument D:\src\path_to_app\main\target\webapp 
  • 使用D:\test\instrument的检测类文件覆盖D:\src\path_to_app\main\target\webapp的类文件。

  • 通过Catalina conf或war文件在Tomcat中部署应用程序。 (该应用程序不起作用)

是否有人使用Cobertura检测的类在Tomcat中正确部署应用程序的正确步骤?

参考: http : //cobertura.sourceforge.net/faq.html

我正在使用cobertura-1.9.4.1

正确的步骤是:

  • 编译应用程序
  • 检测类文件。 D:\test\cobertura-1.9.4.1\cobertura-instrument.bat --destination D:\test\instrument D:\src\path_to_app\main\target\webapp (创建的cobertura.ser)

  • 使用D:\test\instrument的检测类文件覆盖D:\src\path_to_app\main\target\webapp的类文件。

  • 将cobertura.jar复制到WEB-INF / lib
  • 直接在Tomcat中或通过war文件部署应用程序。
  • 将cobertura.ser复制到tomcat的当前目录(tomcat / bin或system32,否则您将在错误日志中看到路径)
  • 使用该应用程序,并停止tomcat服务器。
  • 使用更新的cobertura.ser构建报告(在system32或…中)(至少对我来说,大小不会改变)

参考: – http://cobertura.sourceforge.net/faq.html – JB Nizet的回答

“应用不起作用”是什么意思? 你在tomcat输出/日志中有exception吗? 它说什么?

我怀疑你在部署它之前忘了将cobertura jar放在webapp的WEB-INF / lib文件夹中。 显然,cobertura工具添加的代码调用cobertura引擎的方法,因此这些类必须在您的webapp中可用。