【问题标题】:Cobertura on TomcatTomcat 上的 Cobertura
【发布时间】:2011-07-15 09:11:00
【问题描述】:

我正在尝试使用 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:\src\path_to_app\main\target\webapp的类文件 使用D:\test\instrument 中的检测类文件。

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

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

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

我正在使用 cobertura-1.9.4.1

【问题讨论】:

    标签: java tomcat code-coverage cobertura


    【解决方案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:\src\path_to_app\main\target\webapp的类文件 使用D:\test\instrument 中的检测类文件。

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

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

    【讨论】:

    • 奇怪的是人们如何忽略如此好的答案。谢谢你,兄弟。 +100500 到你的车上。
    【解决方案2】:

    “应用无法运行”是什么意思?您在 tomcat 输出/日志中有异常吗?它说什么?

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

    【讨论】:

      猜你喜欢
      • 2012-01-24
      • 1970-01-01
      • 2016-11-19
      • 2012-02-05
      • 2010-11-28
      • 1970-01-01
      • 2013-04-07
      • 2012-09-30
      • 1970-01-01
      相关资源
      最近更新 更多