Cobertura on Tomcat

痞子三分冷 提交于 2019-12-29 05:27:06

问题


I'm trying to apply code coverage using Cobertura. The app is deployed in Tomcat 5, but when I instrument the .class files, the app stops working.

This are my steps:

  • Compile the app (This run in tomcat)
  • Instrument the class files.

    D:\test\cobertura-1.9.4.1\cobertura-instrument.bat --destination D:\test\instrument D:\src\path_to_app\main\target\webapp
    
  • Overwrite the class files of D:\src\path_to_app\main\target\webapp with the instrumented class files in D:\test\instrument.

  • Deploy the app in Tomcat via Catalina conf or by a war file. (The app does not work)

Does someone have the correct steps for correctly deploying an app in Tomcat with the classes instrumented by Cobertura?

Reference: http://cobertura.sourceforge.net/faq.html

I'm using cobertura-1.9.4.1


回答1:


The correct steps were:

  • Compile the app
  • Instrument the class files. D:\test\cobertura-1.9.4.1\cobertura-instrument.bat --destination D:\test\instrument D:\src\path_to_app\main\target\webapp (a cobertura.ser its created)

  • Overwrite the class files of D:\src\path_to_app\main\target\webapp with the instrumented class files in D:\test\instrument.

  • Copy the cobertura.jar to WEB-INF/lib
  • Deploy the app in Tomcat directly or by a war file.
  • Copy the cobertura.ser to the current dir of tomcat (tomcat/bin or system32, or else you will see the path in the error logs)
  • Use the app, and stop the tomcat server.
  • Build the report with the updated cobertura.ser(in system32 or ...) (at least for me, the size does not change)

Reference: - http://cobertura.sourceforge.net/faq.html - JB Nizet answer




回答2:


What does "the app does not work" mean? Do you have an exception in the tomcat output/logs? What does it say?

I suspect you forgot to put the cobertura jars in the WEB-INF/lib folder of your webapp before deploying it. Obviously, the code addd by the cobertura instrumentation calls methods of the cobertura engine, so these classes must be available in your webapp.



来源:https://stackoverflow.com/questions/5305226/cobertura-on-tomcat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!