jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kelly C. Goedert" <kelly.goed...@nexxera.com>
Subject Re: clover-plugin
Date Thu, 02 Sep 2004 17:08:28 GMT
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

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.dir>
                  </properties>
        </dependency>

3. maven clover:on war

4. maven cactus

5. maven clover:report

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:

>Hi Kelly,
>
>I guess that would be more a Cactus question. Let me try to answer as I've
>already 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 that
>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:kelly.goedert@nexxera.com]
>>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: users-unsubscribe@maven.apache.org
>>For additional commands, e-mail: users-help@maven.apache.org
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: cactus-user-help@jakarta.apache.org
>
>  
>


Mime
View raw message