在websphere中使用cobertura

我们的项目是一个J2EE的项目,涉及了spring,hibernate,struts,EJB。部署在websphere上,本地的开发环境是IBM RAD。项目组自己开发了一个基于JUnit的测试框架,可以通过JSP调用测试类得出测试结果。美中不足的是该框架得不到代码覆盖率。于是我们决定引入cobertura.

分析cobertura自带的example的bulid.xml我们可以将其分解成几个步骤:

1.编译源代码,该步骤其实IDE已经替我们完成了,不需要通过ant去编译,所以省去.

Java代码

<target name="compile" depends="init">
  <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="yes">
  <classpath refid="cobertura.classpath" />
  </javac>
</target>

2.instrument,在这里cobertura生成了instrument后的源代码。并生成cobertura.ser信息文件,该文件很重要,包含了需要被测试的类的信息。

Java代码

<target name="instrument" depends="init,compile">
  <!--
  Remove the coverage data file and any old instrumentation.
  -->
  <delete file="cobertura.ser"/>
  <!--<delete dir="${instrumented.dir}" />
-->
  <!--
  Instrument the application classes, writing the
  instrumented classes into ${build.instrumented.dir}.
  -->
  <cobertura-instrument todir="${instrumented.dir}">
  <!--
   The following line causes instrument to ignore any
   source line containing a reference to log4j, for the
   purposes of coverage reporting.
  -->
  <ignore regex="org.apache.log4j.*" />

  <fileset dir="${classes.dir}">
   <!--
   Instrument all the application classes, but
   don't instrument the test classes.
   -->
   <include name="**/*.class" />
   <exclude name="**/*Test.class" />
  </fileset>
  </cobertura-instrument>
</target>

时间: 2024-08-22 11:27:41

在websphere中使用cobertura的相关文章

关于websphere中jvm的定制变量读取问题

问题描述 我在webspere的管理控制台下servers->servertypes->WebSphereapplicationservers->server1->ServerInfrastructure->JavaandProcessManagement->Processdefinition->JavaVirtualMachine->Customproperties下面定制了自己的变量,名字叫myroot,值是d:/test在我的web应用中使用如下语句读

cas在websphere中的实现

问题描述 cas在websphere中的实现 如何将cas客户端部署在websphere中,找了很多资料都没找到,哪位大神那里有相关的资料?能提供一下吗,不胜感谢. 解决方案 不好意思,没有相关的资料,有空帮你找找.

java程序部署在WebSphere中的问题

问题描述 我有一个WEB程序,把它打成war包 ,然后在websphere中部署, 请求时报错D:IBMWebSphereprofilesdefaultinstalledAppsOuYangNode01Cellmylog_war.earmylog.warException[08-7-4 14:08:52:000 CST] 00000022 WebApp E SRVE0026E: [Servlet 错误]-[/index.jsp]:javax.servlet.jsp.JspException: C

gradle中使用cobertura做代码覆盖(转)

gradle很好用,但是默认是没有代码覆盖功能的,只好自己写.曾经在网上找到过别人的一段脚本,虽然也能用,但是有一些不爽的地方,一个原因是它不支持对层级工程中全部代码的覆盖,另一个原因是它用替换build/classes/main里面的class文件,再依赖gradle的单元方式来实现的.我自己写了一个代码覆盖的脚本,可以避免这两个问题,代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

Websphere中静态资源配置

Tomcat, Jetty, JBoss, GlassFish 自带的默认Servlet的名字 default Google App Engine 自带的 默认Servlet的名字 ah_default Resin 自带的 默认Servlet的名字 resin-file WebLogic 自带的 默认Servlet的名字 FileServlet WebSphere 自带的 默认Servlet的名字 SimpleFileServlet 使用方法: 在项目的web.xml中新增如下配置 <servl

websphere中dwr报Failed to read input

问题描述 我在tomcat中没有出现这个问题,在websphere中表单提交查询的页面除第一个页面外其他都会报failedtoreadinput.很多地方都说过滤dwr包中的alert..但是没有解决本质的问题,虽不会再提示错误,但是还是没有调用的方法 解决方案 解决方案二:帮顶.我的dwr在weblogic8中也有不能生成业务脚本的问题.解决方案三:不懂dwr解决方案四:sdfsfsdf解决方案五:好像有很多种解决方案六:我的这个问题是我粗心造成的.条件查询的按钮<inputtype="

在websphere中使用response.encodeURL不生效

问题描述 在cookie被禁用时,我在tomcat里面使用response.encodeURL,系统会自动帮我加上一个jsessionid,但是部署到was上之后,没有加上jsessionid这个参数了,而且我也在控制台选项里面选择了URL重写选项,请问我要如何获得到was中完整的sessionid,而不是通过session.getid()的到这种. 解决方案

websphere 中html 访问慢的问题

问题描述 我在把项目部署到websphere上出现一些问题.前台页面很慢项目分为前后台,后台是普通的javaweb工程,访问正常,速度很快.前台为静态化后的html,与数据库交互较少,速度慢.不太像是数据库连接池的问题,后台的数据库操作较多(访问正常,速度很快),也把数据库连接池本来是C3P0,现在改为了was的连接池,问题一样存在.跟踪http请求,问题好像静态html的请求时间很长,每次请求延迟4~5秒.也不太像服务器硬件不够的问题,机器资源CPU,内存并没有很慢,也换了3台机机器的was,

websphere中部署出现异常,100分求高手解惑

问题描述 java.lang.reflect.InvocationTargetExceptionatsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet