Cucumber + Cobertura + Maven | Need help

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Cucumber + Cobertura + Maven | Need help

Sapan deka

Hi,

I have some cucumber tests which I plan to run with build integration
through Jenkins. I have maven 3

Currently,

I run integration-test with cucumber cases (say: with tag@abc in feature
files) with following command and pom.xml snippet -

pom.xml snippet: ...
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.11</version> <configuration>
    <skip>true</skip> </configuration>
    <executions>
        <execution>
            <phase>integration-test</phase>
            <goals>
                <goal>test</goal>
            </goals>
            <configuration>
                <skip>false</skip>
                <includes>
                    <include>**/*.class</include>
                </includes>
                <systemPropertyVariables>
                <job.host.name>server-t10</job.host.name>
                <job.email.notification>[hidden email]</job.email.notification>
                <cucumber.options>--format pretty --format
html:target/cucumber/cucumber-html</cucumber.options>
</systemPropertyVariables>
            </configuration>
        </execution>
    </executions>
</plugin> ...



mvn command to run the test case:
mvn clean integration-test -Dcucumber.options="--format pretty --format
html:target/cucumber/cucumber-html1 --tags @abc" -Djob.host.name=server-t10

Every thing works fine with cases being executed and all reports produced.
The problem arises when i try to get the coverage of the test cases.

I tried all possible combination to generate a cobertura coverage report
with cobertura-maven-plugin and version2.5.2 (without using ant
instrumnet/report), but it just does not create any report, nor any .ser
file or anything. Only logs say that - No files to instrument and does
nothing.

Loosing the battle, finally, i downloaded cobertura (1.9.4.1) and created
custom cobertura.xml. And when i run the following ant commands for ex -

ant -f cobertura.xml instrument

mvn clean integration-test -Dcucumber.options="--format pretty --format
html:target/cucumber/cucumber-html1 --tags @abc" -Djob.host.name=server-t10

ant -f cobertura.xml report

Luckily though, it creates all the reports/.ser file etc. however after
running all of it, it shows as zero coverage in the final coverage report
for all used classes. That could be because (as i think), the mvn command
did not use/manipulate the cobertura.ser created by ant instrument command.

So, please help me out in this, that what and where i put something in my
pom.xml so that when i run the mvn command (after ant instrumentation), it
uses the instrumented file (created earlier) and update it. so that i can
use that file for my report generation using ant report. I tried putting
all possible entries in pom.xml. but it did not help.

Note: I am looking for this particular solution because all my effort have
gone waste trying to make cobertura-maven-plugun work. I dont' know the
reason but this plugin just doesn't work for me for creating report or even
running the cases.

I would also like to know what is the issue that maven-cobertura-plugin is
not at all working in my case.

Please help me out in this. Please ... Please

p.s. forgive my formatting

Below is the POM if you wish to look -

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.cukes.cobertura</groupId>
  <artifactId>CukesPOC</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>CoberturaCukesPOC</name>
  <url>http://maven.apache.org</url>

    <repositories>
        <repository>
            <id>maven</id>
            <url>http://repo1.maven.org/maven2</url>
        </repository>
        <repository>
            <id>sonatype-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots
</url>
        </repository>
        <repository>
            <id>nextag</id>
            <url>http://crepo.corp.nextag.com/repo/libraries/maven2</url>
        </repository>
        <repository>
            <id>nextag repo2</id>
            <url>http://crepo.corp.nextag.com/repo/components2</url>
        </repository>
    </repositories>

    <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<surefire.report.location>target/surefire-reports1</surefire.report.location>
    </properties>

    <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.1.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>1.1.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.1.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>1.1.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.30.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.picocontainer</groupId>
            <artifactId>picocontainer</artifactId>
            <version>2.14.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc14</artifactId>
            <version>10.2.0.4.0</version>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.cobertura</groupId>
            <artifactId>cobertura</artifactId>
            <optional>true</optional>
            <version>1.9.4.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                  <configuration>
                      <source>1.5</source>
                      <target>1.5</target>
                  </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.5.2</version>
                <executions>
                    <execution>
                        <id>instrument</id>
                        <phase>site</phase>
                        <goals>
                            <goal>instrument</goal>
                            <goal>cobertura</goal>
                        </goals>
                    </execution>
                </executions>
                  <configuration>
                    <instrumentation>
                        <includes>
                            <include>**/*.class</include>
                        </includes>
                    </instrumentation>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.11</version>
                <configuration>
                    <!-- Skip the normal tests, we'll run them in the
integration-test phase -->
                    <skip>true</skip>
                </configuration>
                <executions>
                    <execution>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skip>false</skip>
                            <includes>
                                <include>**/*.class</include>
                            </includes>
                            <systemPropertyVariables>
                                <job.host.name>server-t10</job.host.name>
                                <job.email.notification>[hidden email]
</job.email.notification>
                                <cucumber.options>--format pretty --format
html:target/cucumber/cucumber-html</cucumber.options>
                            </systemPropertyVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


            <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-surefire-report-plugin</artifactId>
                   <configuration>

<outputDirectory>${surefire.report.location}</outputDirectory>
                   </configuration>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>report-only</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <reporting>
        <plugins>
            <plugin>
            <!-- use mvn cobertura:cobertura to generate cobertura reports
-->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.5.2</version>
            </plugin>
        </plugins>
     </reporting>
</project>
Reply | Threaded
Open this post in threaded view
|

Re: Cucumber + Cobertura + Maven | Need help

Robert Scholte-3
Hi,

try to run it with debug logging, so add -X to your Maven commandline.
That will show you why there are no files to instrument.

Robert

ps. only mailing to the user mailinglist is good enough.


On Thu, 07 Mar 2013 04:27:19 +0100, Sapan deka <[hidden email]>  
wrote:

> Hi,
>
> I have some cucumber tests which I plan to run with build integration
> through Jenkins. I have maven 3
>
> Currently,
>
> I run integration-test with cucumber cases (say: with tag@abc in feature
> files) with following command and pom.xml snippet -
>
> pom.xml snippet: ...
> <plugin>
>     <groupId>org.apache.maven.plugins</groupId>
>     <artifactId>maven-surefire-plugin</artifactId>
>     <version>2.11</version> <configuration>
>     <skip>true</skip> </configuration>
>     <executions>
>         <execution>
>             <phase>integration-test</phase>
>             <goals>
>                 <goal>test</goal>
>             </goals>
>             <configuration>
>                 <skip>false</skip>
>                 <includes>
>                     <include>**/*.class</include>
>                 </includes>
>                 <systemPropertyVariables>
>                 <job.host.name>server-t10</job.host.name>
>                 <job.email.notification>[hidden email]</job.email.notification>
>                 <cucumber.options>--format pretty --format
> html:target/cucumber/cucumber-html</cucumber.options>
> </systemPropertyVariables>
>             </configuration>
>         </execution>
>     </executions>
> </plugin> ...
>
>
>
> mvn command to run the test case:
> mvn clean integration-test -Dcucumber.options="--format pretty --format
> html:target/cucumber/cucumber-html1 --tags @abc"  
> -Djob.host.name=server-t10
>
> Every thing works fine with cases being executed and all reports  
> produced.
> The problem arises when i try to get the coverage of the test cases.
>
> I tried all possible combination to generate a cobertura coverage report
> with cobertura-maven-plugin and version2.5.2 (without using ant
> instrumnet/report), but it just does not create any report, nor any .ser
> file or anything. Only logs say that - No files to instrument and does
> nothing.
>
> Loosing the battle, finally, i downloaded cobertura (1.9.4.1) and created
> custom cobertura.xml. And when i run the following ant commands for ex -
>
> ant -f cobertura.xml instrument
>
> mvn clean integration-test -Dcucumber.options="--format pretty --format
> html:target/cucumber/cucumber-html1 --tags @abc"  
> -Djob.host.name=server-t10
>
> ant -f cobertura.xml report
>
> Luckily though, it creates all the reports/.ser file etc. however after
> running all of it, it shows as zero coverage in the final coverage report
> for all used classes. That could be because (as i think), the mvn command
> did not use/manipulate the cobertura.ser created by ant instrument  
> command.
>
> So, please help me out in this, that what and where i put something in my
> pom.xml so that when i run the mvn command (after ant instrumentation),  
> it
> uses the instrumented file (created earlier) and update it. so that i can
> use that file for my report generation using ant report. I tried putting
> all possible entries in pom.xml. but it did not help.
>
> Note: I am looking for this particular solution because all my effort  
> have
> gone waste trying to make cobertura-maven-plugun work. I dont' know the
> reason but this plugin just doesn't work for me for creating report or  
> even
> running the cases.
>
> I would also like to know what is the issue that maven-cobertura-plugin  
> is
> not at all working in my case.
>
> Please help me out in this. Please ... Please
>
> p.s. forgive my formatting
>
> Below is the POM if you wish to look -
>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>
>   <groupId>com.cukes.cobertura</groupId>
>   <artifactId>CukesPOC</artifactId>
>   <version>1.0-SNAPSHOT</version>
>   <packaging>jar</packaging>
>
>   <name>CoberturaCukesPOC</name>
>   <url>http://maven.apache.org</url>
>
>     <repositories>
>         <repository>
>             <id>maven</id>
>             <url>http://repo1.maven.org/maven2</url>
>         </repository>
>         <repository>
>             <id>sonatype-snapshots</id>
>             <url>https://oss.sonatype.org/content/repositories/snapshots
> </url>
>         </repository>
>         <repository>
>             <id>nextag</id>
>             <url>http://crepo.corp.nextag.com/repo/libraries/maven2</url>
>         </repository>
>         <repository>
>             <id>nextag repo2</id>
>             <url>http://crepo.corp.nextag.com/repo/components2</url>
>         </repository>
>     </repositories>
>
>     <properties>
>       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>
> <surefire.report.location>target/surefire-reports1</surefire.report.location>
>     </properties>
>
>     <dependencies>
>         <dependency>
>             <groupId>info.cukes</groupId>
>             <artifactId>cucumber-java</artifactId>
>             <version>1.1.2</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>info.cukes</groupId>
>             <artifactId>cucumber-core</artifactId>
>             <version>1.1.2</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>info.cukes</groupId>
>             <artifactId>cucumber-junit</artifactId>
>             <version>1.1.2</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>info.cukes</groupId>
>             <artifactId>cucumber-picocontainer</artifactId>
>             <version>1.1.2</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>junit</groupId>
>             <artifactId>junit</artifactId>
>             <version>4.11</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.seleniumhq.selenium</groupId>
>             <artifactId>selenium-java</artifactId>
>             <version>2.30.0</version>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.httpcomponents</groupId>
>             <artifactId>httpcore</artifactId>
>             <version>4.2.3</version>
>         </dependency>
>         <dependency>
>             <groupId>org.picocontainer</groupId>
>             <artifactId>picocontainer</artifactId>
>             <version>2.14.1</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>com.oracle</groupId>
>             <artifactId>ojdbc14</artifactId>
>             <version>10.2.0.4.0</version>
>         </dependency>
>         <dependency>
>             <groupId>net.sourceforge.cobertura</groupId>
>             <artifactId>cobertura</artifactId>
>             <optional>true</optional>
>             <version>1.9.4.1</version>
>         </dependency>
>     </dependencies>
>
>     <build>
>         <plugins>
>             <plugin>
>                     <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-compiler-plugin</artifactId>
>                   <configuration>
>                       <source>1.5</source>
>                       <target>1.5</target>
>                   </configuration>
>             </plugin>
>
>             <plugin>
>                 <groupId>org.codehaus.mojo</groupId>
>                 <artifactId>cobertura-maven-plugin</artifactId>
>                 <version>2.5.2</version>
>                 <executions>
>                     <execution>
>                         <id>instrument</id>
>                         <phase>site</phase>
>                         <goals>
>                             <goal>instrument</goal>
>                             <goal>cobertura</goal>
>                         </goals>
>                     </execution>
>                 </executions>
>                   <configuration>
>                     <instrumentation>
>                         <includes>
>                             <include>**/*.class</include>
>                         </includes>
>                     </instrumentation>
>                 </configuration>
>             </plugin>
>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-surefire-plugin</artifactId>
>                 <version>2.11</version>
>                 <configuration>
>                     <!-- Skip the normal tests, we'll run them in the
> integration-test phase -->
>                     <skip>true</skip>
>                 </configuration>
>                 <executions>
>                     <execution>
>                         <phase>integration-test</phase>
>                         <goals>
>                             <goal>test</goal>
>                         </goals>
>                         <configuration>
>                             <skip>false</skip>
>                             <includes>
>                                 <include>**/*.class</include>
>                             </includes>
>                             <systemPropertyVariables>
>                                 <job.host.name>server-t10</job.host.name>
>                                 <job.email.notification>[hidden email]
> </job.email.notification>
>                                 <cucumber.options>--format pretty  
> --format
> html:target/cucumber/cucumber-html</cucumber.options>
>                             </systemPropertyVariables>
>                         </configuration>
>                     </execution>
>                 </executions>
>             </plugin>
>
>
>             <plugin>
>                    <groupId>org.apache.maven.plugins</groupId>
>                    <artifactId>maven-surefire-report-plugin</artifactId>
>                    <configuration>
>
> <outputDirectory>${surefire.report.location}</outputDirectory>
>                    </configuration>
>                 <executions>
>                     <execution>
>                         <phase>test</phase>
>                         <goals>
>                             <goal>report-only</goal>
>                         </goals>
>                     </execution>
>                 </executions>
>             </plugin>
>         </plugins>
>     </build>
>
>     <reporting>
>         <plugins>
>             <plugin>
>             <!-- use mvn cobertura:cobertura to generate cobertura  
> reports
> -->
>                 <groupId>org.codehaus.mojo</groupId>
>                 <artifactId>cobertura-maven-plugin</artifactId>
>                 <version>2.5.2</version>
>             </plugin>
>         </plugins>
>      </reporting>
> </project>


--
Using Opera's revolutionary email client: http://www.opera.com/mail/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email