You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Rick <ri...@gmail.com> on 2008/12/22 07:03:54 UTC

how to get cobertura tasks to run on "mvn install" ?

This is newbie I know, but I don't see how I get my
cobertura:cobertura task (or maybe cobertura:check) to always run when
I do a build with "mvn clean install." I might change it later, but
for now I'd like the text coverage cobertura task to always run.

I don't get what is causing the mvn tests to run when i do mvn install
but not the cobertura tasks?

-- 
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: how to get cobertura tasks to run on "mvn install" ?

Posted by Rick <ri...@gmail.com>.
Actually, hold on, the main reason it wasn't working was because I was
an iidiot!!!!!!
blah.
Look how I had the execution code inside the configuration code! DOH!

Thanks though for your patience. One of those cases where explaining
what I was doing to someone pointed me to my error.

On Mon, Dec 22, 2008 at 9:43 AM, Stephen Connolly
<st...@gmail.com> wrote:
> "clean" is the only phase on the clean lifecycle.
>
> you want a phase on the build lifecycle...
>
> Also, you want a phase after the tests have been compiled, and probably
> after the tests have ran (to ensure you measure the coverage of working
> tests... coverage of broken tests is usually meaningless, as you are
> executing unplanned paths)
>
> Now for my standard disclaimer:
>
> "RUN THE DAMN TESTS TWICE!"
>
> I have seen:
>
> 1, Tests that fail when run without coverage but pass when run with
> coverage.
> 2. Tests that pass when run without coverage but fail when run with
> coverage.
>
> I have seen both 1 & 2 far more often that you think.
>
> In *MOST* cases of #1 and in about half the cases of #2 this has been
> because the developer did not understand the code optimizations that the JVM
> is allowed to make. In every one of these cases, switching to another valid
> JVM implementation has reproduced the issue.
>
> In the other half of the cases of #2 this has been because they are
> performance tests... and they would be expected to fail when coverage has
> instrumented the code.
>
> Do you have more than one thread? Run the tests twice.
>
> -Stephen
>
> 2008/12/22 Rick <ri...@gmail.com>
>
>> On Mon, Dec 22, 2008 at 4:04 AM, Stephen Connolly
>> <st...@gmail.com> wrote:
>> >
>> > The Sonatype book is good, and available free online and there are other
>> > good tutorials.  A 3-4 hours quick skim is most definitely not a waste of
>> > your time.
>>
>> Actually I did read the sontatype book. I reread the chapter on "the
>> build lifecycle" and it sounds like (following what is described in
>> section 10.1) if I added the phase 'clean' and goal 'cobertura' that
>> it should run the cobertura goal when the mvn clean phase is reached?
>> Yes I don't see this happening. I even tried different phases.
>>
>> Under the plugin section under build I have (other plugins removed for
>> clarity)
>>
>> <?xml version="1.0"?>
>> <build>
>>        <plugins>
>>                <plugin>
>>                        <groupId>org.codehaus.mojo</groupId>
>>                        <artifactId>cobertura-maven-plugin</artifactId>
>>                        <configuration>
>>                                <instrumentation>
>>                                        <excludes>
>>
>>  <exclude>com/foo/ondp/**/*Test.class</exclude>
>>                                        </excludes>
>>                                </instrumentation>
>>                                <executions>
>>                                        <execution>
>>                                                <phase>clean</phase>
>>                                                <goals>
>>
>>  <goal>cobertura</goal>
>>                                                </goals>
>>                                        </execution>
>>                                </executions>
>>                        </configuration>
>>                </plugin>
>>        </plugins>
>> </build>
>>
>>
>> If I manually run mvn cobertura:cobertura it runs fine.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>



-- 
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: how to get cobertura tasks to run on "mvn install" ?

Posted by Stephen Connolly <st...@gmail.com>.
on this issue I am pedantic

too many people will be stupid and not run the tests twice, and they  
will have a false sense of security

If you want to go against my advice I have given as much of a pointer  
as I'm willing to give

sorry, but I say run them twice period, no ifs ands or buts.

day to day development is using the IDE which maven ensures is  
configured nicely

the CI server runs the maven lifecycle and tracks coverage as well as  
test quality


Sent from my iPod

On 23 Dec 2008, at 03:58, Rick <ri...@gmail.com> wrote:

> On Mon, Dec 22, 2008 at 9:43 AM, Stephen Connolly
> <st...@gmail.com> wrote:
>
>> Now for my standard disclaimer:
>>
>> "RUN THE DAMN TESTS TWICE!"
>>
>> I have seen:
>>
>> 1, Tests that fail when run without coverage but pass when run with
>> coverage.
>> 2. Tests that pass when run without coverage but fail when run with
>> coverage.
>
> Stephen, I actually saw your post come up stating the same thing while
> searching for "how I make sure cobertura only runs the tests once" in
> this thread here
> http://www.nabble.com/cobertura-%2B-surefire-config-td16281994.html
>
> I understand what you are saying about being sure that they are run
> twice (once before instrumentation), but for general use during the
> course of the day I'd still like to shorten the cycle by only having
> the tests run one time. You mention to use a profile to accomplish
> this, and I'm trying different things to no avail. If I disable the
> surefire plugin in my plugin the tests never run, so I'm confused what
> to do?
>
> I'm confused on how I'm supposed to set up the profile to only run the
> test suite once after instrumentation?
>
> I was trying a profile like below which I thought might work. I
> thought maybe cobertura would still force the tests to run even with
> the surefire plugin was set to skip, but in this scenario I get no
> tests run.  If I remove the surefire plugin from the profile, I'll end
> up with the tests run twice.
>
> Thanks for any help.
>
> <profile>
>    <id>coverage</id>
>    <build>
>        <plugins>
>            <plugin>
>                <groupId>org.codehaus.mojo</groupId>
>                <artifactId>cobertura-maven-plugin</artifactId>
>                <configuration>
>                    <instrumentation>
>                         ....
>                    </instrumentation>
>                </configuration>
>                <executions>
>                    <execution>
>                        <phase>test</phase>
>                        <goals>
>                            <goal>cobertura</goal>
>                        </goals>
>                    </execution>
>                </executions>
>            </plugin>
>            <plugin>
>                <groupId>org.apache.maven.plugins</groupId>
>                <artifactId>maven-surefire-plugin</artifactId>
>                <version>2.4.2</version>
>                <configuration>
>                    <skip>true</skip>
>                </configuration>
>            </plugin>
>        </plugins>
>    </build>
> </profile>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: how to get cobertura tasks to run on "mvn install" ?

Posted by Rick <ri...@gmail.com>.
On Mon, Dec 22, 2008 at 9:43 AM, Stephen Connolly
<st...@gmail.com> wrote:

> Now for my standard disclaimer:
>
> "RUN THE DAMN TESTS TWICE!"
>
> I have seen:
>
> 1, Tests that fail when run without coverage but pass when run with
> coverage.
> 2. Tests that pass when run without coverage but fail when run with
> coverage.

Stephen, I actually saw your post come up stating the same thing while
searching for "how I make sure cobertura only runs the tests once" in
this thread here
http://www.nabble.com/cobertura-%2B-surefire-config-td16281994.html

I understand what you are saying about being sure that they are run
twice (once before instrumentation), but for general use during the
course of the day I'd still like to shorten the cycle by only having
the tests run one time. You mention to use a profile to accomplish
this, and I'm trying different things to no avail. If I disable the
surefire plugin in my plugin the tests never run, so I'm confused what
to do?

I'm confused on how I'm supposed to set up the profile to only run the
test suite once after instrumentation?

I was trying a profile like below which I thought might work. I
thought maybe cobertura would still force the tests to run even with
the surefire plugin was set to skip, but in this scenario I get no
tests run.  If I remove the surefire plugin from the profile, I'll end
up with the tests run twice.

Thanks for any help.

<profile>
    <id>coverage</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <configuration>
                    <instrumentation>
                         ....
                    </instrumentation>
                </configuration>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>cobertura</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.4.2</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: how to get cobertura tasks to run on "mvn install" ?

Posted by Stephen Connolly <st...@gmail.com>.
"clean" is the only phase on the clean lifecycle.

you want a phase on the build lifecycle...

Also, you want a phase after the tests have been compiled, and probably
after the tests have ran (to ensure you measure the coverage of working
tests... coverage of broken tests is usually meaningless, as you are
executing unplanned paths)

Now for my standard disclaimer:

"RUN THE DAMN TESTS TWICE!"

I have seen:

1, Tests that fail when run without coverage but pass when run with
coverage.
2. Tests that pass when run without coverage but fail when run with
coverage.

I have seen both 1 & 2 far more often that you think.

In *MOST* cases of #1 and in about half the cases of #2 this has been
because the developer did not understand the code optimizations that the JVM
is allowed to make. In every one of these cases, switching to another valid
JVM implementation has reproduced the issue.

In the other half of the cases of #2 this has been because they are
performance tests... and they would be expected to fail when coverage has
instrumented the code.

Do you have more than one thread? Run the tests twice.

-Stephen

2008/12/22 Rick <ri...@gmail.com>

> On Mon, Dec 22, 2008 at 4:04 AM, Stephen Connolly
> <st...@gmail.com> wrote:
> >
> > The Sonatype book is good, and available free online and there are other
> > good tutorials.  A 3-4 hours quick skim is most definitely not a waste of
> > your time.
>
> Actually I did read the sontatype book. I reread the chapter on "the
> build lifecycle" and it sounds like (following what is described in
> section 10.1) if I added the phase 'clean' and goal 'cobertura' that
> it should run the cobertura goal when the mvn clean phase is reached?
> Yes I don't see this happening. I even tried different phases.
>
> Under the plugin section under build I have (other plugins removed for
> clarity)
>
> <?xml version="1.0"?>
> <build>
>        <plugins>
>                <plugin>
>                        <groupId>org.codehaus.mojo</groupId>
>                        <artifactId>cobertura-maven-plugin</artifactId>
>                        <configuration>
>                                <instrumentation>
>                                        <excludes>
>
>  <exclude>com/foo/ondp/**/*Test.class</exclude>
>                                        </excludes>
>                                </instrumentation>
>                                <executions>
>                                        <execution>
>                                                <phase>clean</phase>
>                                                <goals>
>
>  <goal>cobertura</goal>
>                                                </goals>
>                                        </execution>
>                                </executions>
>                        </configuration>
>                </plugin>
>        </plugins>
> </build>
>
>
> If I manually run mvn cobertura:cobertura it runs fine.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: how to get cobertura tasks to run on "mvn install" ?

Posted by Rick <ri...@gmail.com>.
On Mon, Dec 22, 2008 at 4:04 AM, Stephen Connolly
<st...@gmail.com> wrote:
>
> The Sonatype book is good, and available free online and there are other
> good tutorials.  A 3-4 hours quick skim is most definitely not a waste of
> your time.

Actually I did read the sontatype book. I reread the chapter on "the
build lifecycle" and it sounds like (following what is described in
section 10.1) if I added the phase 'clean' and goal 'cobertura' that
it should run the cobertura goal when the mvn clean phase is reached?
Yes I don't see this happening. I even tried different phases.

Under the plugin section under build I have (other plugins removed for clarity)

<?xml version="1.0"?>
<build>
	<plugins>
		<plugin>
			<groupId>org.codehaus.mojo</groupId>
			<artifactId>cobertura-maven-plugin</artifactId>
			<configuration>
				<instrumentation>
					<excludes>
						<exclude>com/foo/ondp/**/*Test.class</exclude>
					</excludes>
				</instrumentation>
				<executions>
					<execution>
						<phase>clean</phase>
						<goals>
							<goal>cobertura</goal>
						</goals>
					</execution>
				</executions>
			</configuration>
		</plugin>
	</plugins>
</build>


If I manually run mvn cobertura:cobertura it runs fine.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: how to get cobertura tasks to run on "mvn install" ?

Posted by Stephen Connolly <st...@gmail.com>.
You need to bind the plugin to a phase in them lifecycle.

It sounds like you are rushing ahead without reading a basic primer on
Maven's concepts.

The Sonatype book is good, and available free online and there are other
good tutorials.  A 3-4 hours quick skim is most definitely not a waste of
your time.

-Stephen

2008/12/22 Rick <ri...@gmail.com>

> This is newbie I know, but I don't see how I get my
> cobertura:cobertura task (or maybe cobertura:check) to always run when
> I do a build with "mvn clean install." I might change it later, but
> for now I'd like the text coverage cobertura task to always run.
>
> I don't get what is causing the mvn tests to run when i do mvn install
> but not the cobertura tasks?
>
> --
> Rick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>