Vincent Massol wrote:
-----Original Message----- From: Kelly C. Goedert [mailto:[EMAIL PROTECTED] Sent: jeudi 2 septembre 2004 19:08 To: Cactus Users List Subject: Re: clover-plugin
Hello Vincent,
thanks for trying to help me again. I followed what you said but still my servlet tests(built with cactus) are not being show as covered on the report. Here is what I did:
1. Put clover database property on project.properties like this
maven.clover.database.dir=target/clover/database
Took it off
Actually in your case it's not required as you've got a single maven project. It is only required for multiproject builds.
2. Put the clover dependency on the project: <dependency> <groupId>clover</groupId> <artifactId>clover-ant</artifactId> <version>1.3_01</version> <properties> <cactus.bundle>true</cactus.bundle>
<maven.clover.database.dir>target/clover/database</maven.clover.database.d
ir>
Errr? What's this? :-)
This is something I didn't know how configure to be true (how it should be done?????)
</properties> </dependency>
3. maven clover:on war
Does your code get clovered? (you can show us the console output)
This is the output
[EMAIL PROTECTED]:~/workspace/MavenCC$ maven clover:on war __ __ | \/ |__ _Apache__ ___ | |\/| / _` \ V / -_) ' \ ~ intelligent projects ~ |_| |_\__,_|\_/\___|_||_| v. 1.0
build:start:
clover:init:
[mkdir] Created dir: /home/kelly/workspace/MavenCC/target/clover/classes
[mkdir] Created dir: /home/kelly/workspace/MavenCC/target/clover/database
[mkdir] Created dir: /home/kelly/workspace/MavenCC/target/docs/clover
clover:on:
[echo] Setting Clover compiler
[echo] Now using primary build.compiler : org.apache.tools.ant.taskdefs.CloverCompilerAdapter
war:init:
java:prepare-filesystem:
java:compile:
[echo] Compiling to /home/kelly/workspace/MavenCC/target/clover/classes
[javac] Compiling 2 source files to /home/kelly/workspace/MavenCC/target/clover/classes
[javac] Clover Version 1.2.3, built on October 20 2003
[javac] loaded from: file:/home/kelly/.maven/repository/clover/jars/clover-1.2.3.jar
[javac] 30 day Evaluation Version distributed via the Maven Jar Repository.
[javac] Clover is not free. You have 30 days to evaluate it.
[javac] Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
[javac] No coverage database '/home/kelly/workspace/MavenCC/target/clover/database/clover_coverage.db' found. Creating a fresh one.
[javac] Clover all over. Instrumented 2 files.
java:jar-resources:
test:prepare-filesystem: [mkdir] Created dir: /home/kelly/workspace/MavenCC/target/test-classes [mkdir] Created dir: /home/kelly/workspace/MavenCC/target/test-reports
test:test-resources:
test:compile:
[javac] Compiling 1 source file to /home/kelly/workspace/MavenCC/target/test-classes
[javac] Clover Version 1.2.3, built on October 20 2003
[javac] loaded from: file:/home/kelly/.maven/repository/clover/jars/clover-1.2.3.jar
[javac] 30 day Evaluation Version distributed via the Maven Jar Repository.
[javac] Clover is not free. You have 30 days to evaluate it.
[javac] Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
[javac] Updating database at '/home/kelly/workspace/MavenCC/target/clover/database/clover_coverage.db'
[javac] Clover all over. Instrumented 0 files.
test:test: [junit] Running com.nexxera.TestSoma [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.604 sec
war:webapp:
[echo] Assembling webapp mavencc
[mkdir] Created dir: /home/kelly/workspace/MavenCC/target/mavencc
[mkdir] Created dir: /home/kelly/workspace/MavenCC/target/mavencc/WEB-INF
[mkdir] Created dir: /home/kelly/workspace/MavenCC/target/mavencc/WEB-INF/lib
[mkdir] Created dir: /home/kelly/workspace/MavenCC/target/mavencc/WEB-INF/tld
[mkdir] Created dir: /home/kelly/workspace/MavenCC/target/mavencc/WEB-INF/classes
[copy] Copying 1 file to /home/kelly/workspace/MavenCC/target/mavencc/WEB-INF
war:war:
[echo] Building WAR mavencc
[jar] Building jar: /home/kelly/workspace/MavenCC/target/mavencc-build.war
BUILD SUCCESSFUL
Total time: 9 seconds
Finished at: Thu Sep 02 14:33:09 BRT 2004
4. maven cactus
5. maven clover:report
[snip]
I've just tried it on the cactus sample (http://cvs.apache.org/viewcvs.cgi/jakarta-cactus/integration/maven/samples/ servlet/) by typing:
maven clover:on cactus
and then
maven clover:report
and it worked fine... (showing 74% test coverage)
Maybe you're using old versions of the Maven Clover plugin or the Cactus plugin for Maven?
The versions are clover-plugin 1.5 and cactus plugin 1.6
Kelly.
Thanks -Vincent
All the commands were successful, but my report only shows as the classes that are not servlets are covered. Bellow is my servlet and its test class.
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest;
public class SampleServlet extends HttpServlet { public void saveToSession(HttpServletRequest request) { String testparam = request.getParameter("testparam"); request.getSession().setAttribute("testAttribute", testparam); } }
import junit.framework.Test; import junit.framework.TestSuite;
import org.apache.cactus.ServletTestCase; import org.apache.cactus.WebRequest;
public class TestSampleServlet extends ServletTestCase { public TestSampleServlet(String theName) { super(theName); }
public static Test suite() { return new TestSuite(TestSampleServlet.class); }
public void beginSaveToSessionOK(WebRequest webRequest) { webRequest.addParameter("testparam", "it works!"); }
public void testSaveToSessionOK() { SampleServlet servlet = new SampleServlet(); servlet.saveToSession(request); assertEquals("it works!", session.getAttribute("testAttribute")); }
public void testSaveToSession(){ assertTrue(true); } }
In the console output I can see that all test are executed and pass.
Thaks again
Kelly.
Vincent Massol wrote:
I'veHi Kelly,
I guess that would be more a Cactus question. Let me try to answer as
thatalready done this in Cactus land.
The easiest is to do the following I think:
1/ First run clover on your projects that need clovering (for ex: maven
clover:on war). Ensure that you've set the clover database property so
---------------------------------------------------------------------it points to a single location for all the project you're clovering.
2/ In the project where you run the Cactus tests, ensure to include the clover dependency and tag it as cactus.bundle so that it finds its way in the cactified war.
<dependency> <groupId>clover</groupId> <artifactId>clover-ant</artifactId> <version>1.3_01</version> <properties> <cactus.bundle>true</cactus.bundle> </properties> </dependency>
Of course you also need to define the clover database property so that it points to the same clover database.
3/ Execute the cactus tests (maven cactus)
4/ Execute the clover report.
-Vincent
-----Original Message----- From: Kelly C. Goedert [mailto:[EMAIL PROTECTED] Sent: jeudi 2 septembre 2004 14:47 To: Maven Users List Subject: clover-plugin
Can someone give me an example on how to generate a clover report for cactus tests?
Thanks
Kelly.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
