ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephane Bailliez <stephane.baill...@haht.com>
Subject RE: jpcoverage/junit intergration: how do I capture junit coverag e with with JProbe?
Date Wed, 17 Apr 2002 09:21:13 GMT
Gordon,

I have already answer to Mohamed prior to your his post here but guess I was
not clear. You can achieve what you do easily and avoid extra code stuff.
You just have to call Ant from jpcoverage... not use antcall of course.
Consider Ant as the junit runner here as it does everything you need.

--- build.xml ---
 <target name='run-coverage'>
   <jpcoverage classname='org.apache.tools.ant.Main' ...>
      <jvmarg value="-Dant.home=${ant.home}"/>
	<arg line='-f ${ant.file} run-tests'/>
       ...
   </jpcoverage>
 </target>

 <target name='run-tests'>
   <junit .../>
 </target>
-------------

This is the kind of thing I use for my nightly builds. From the XML I
generate all the reports via <jpcovreport> associated to the tests (and give
meaningful results as well as I use a reference classpath to give coverage
indication...that means it takes into consideration the classes that were
not loaded but are part of the reference classpath, otherwise you will only
have the coverage number for the classes you did test...not the one you did
not and you don't know about. Therefore you are able to know the real
coverage of tests from a given projects. Pretty useful. I have 100% success
for my tests (that cover 5%) and 98% of success for my tests (that cover
70%). It helps focusing the effort.

Stephane

> -----Original Message-----
> From: Gordon Tyler [mailto:gordon.tyler@sitraka.com]
> Sent: Tuesday, April 16, 2002 8:29 PM
> To: Ant Users List
> Subject: Re: jpcoverage/junit intergration: how do I capture junit
> coverage with with JProbe?
> 
> 
> First, a disclaimer: I work at Sitraka (who produces JProbe) 
> but I do not
> work on JProbe itself. I am part of another team at Sitraka 
> which merely
> uses JProbe Coverage with JUnit tests. So I can't give 
> support on JProbe.
> 
> We don't use the jpcoverage or junit tasks because of the 
> limitations that
> you've pointed out but rather we execute jplauncher.exe using 
> an <exec> task
> and pass all the appropriate command-line arguments. Also, we 
> don't execute
> TestRunner directly, but rather a class which we wrote that 
> automatically
> "discovers" all the test classes in our packages and builds a 
> TestSuite
> which it then runs using TestRunner.
> 
> Here's the <exec> task that we use:
> 
> <property name="coverage.home" value="${env.COVERAGE_HOME}"/>
> 
> <exec executable="${coverage.home}/jplauncher.exe">
>         <arg value="-classpath"/>
>         <arg value="YOUR_CLASSPATH_HERE"/>
>         <arg value="-jp_function=coverage"/>
>         <arg value="-jp_java_home=${java.home}"/>
>         <arg value="-jp_java_exe=${java.home}/bin/java.exe"/>
>         <arg value="-jp_vm=java2"/>
>         <arg value="-jp_final_snapshot=coverage"/>
>         <arg value="-jp_ignore_abstract=true"/>
>         <arg value="-jp_record_from_start=coverage"/>
>         <arg value="-jp_output_file=YOUR_OUTPUT_FILENAME_HERE"/>
>         <arg value="-jp_snapshot_dir=YOUR_SNAPSHOT_DIRECTORY_HERE"/>
>         <arg 
> value="-jp_working_dir=YOUR_BUILD_WORKING_DIRECTORY_HERE"/>
>         <arg
> value="-jp_filter=*.*:E,com.acme.product*.*:I,com.acme.product
> .AutoTest:E"/>
>         <arg value="com.acme.product.AutoTest"/>
>         <arg value="-o"/>
>         <arg value="YOUR_LOG_FILENAME_HERE"/>
> </exec>
> 
> The jp_working_dir option should point to a directory where 
> your tests would
> expect to be running from, so that they can find data files, etc. if
> necessary. So in our case that would be our build/dist directory which
> contains the jars and data files of our application.
> 
> The jp_filter option should be changed to use the correct includes and
> excludes for your code.
> 
> com.acme.product.AutoTest is the fictional name of the "test 
> discovery and
> execution" class that I described earlier.
> 
> I don't actually use this myself, it's used by the QA guys on 
> the team, so
> I'm not 100% sure of how it all works ;) It's used in the context of a
> nightly build where there isn't a human to observe it, so I 
> don't think it
> displays the Coverage UI.
> 
> Ciao,
> Gordon
> 
> ----- Original Message -----
> From: "Mohamed, Haneef" <Haneef_Mohamed@G1.com>
> To: <ant-user@jakarta.apache.org>
> Sent: Tuesday, April 16, 2002 1:35 PM
> Subject: jpcoverage/junit intergration: how do I capture 
> junit coverage with
> with JProbe?
> 
> 
> > Hello everyone!
> >
> > Here is the problem I am encountering:
> >
> > Aim
> > To run junit tests and capture code coverage metrics with 
> jprobe as part
> of
> > the build process [pre-deployment]
> > via ant
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:ant-user-help@jakarta.apache.org>
> 

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message