You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stevo Slavić <ss...@gmail.com> on 2009/04/01 15:31:33 UTC
Re: Code coverage reports & Activating profile if (site) plug-in is
run
I must have asked a silly question, or ...
Nevertheless, I'm taking another approach now, by trying to fix
http://jira.codehaus.org/browse/MCOBERTURA-86 issue. To make the cobertura
maven plug-in execute verify phase instead of test phase in cobertura
lifecycle, I've created a new report mojo ("cobertura-integration" goal)
that extends existing cobertura report, with @execute phase attribute set to
verify. Verify is needed so that post-integration-test bound executions can
kick in, e.g. to stop server where application was deployed for functional
testing. In war project pom I've configured jetty, selenium, and surefire
similarly to this<http://www.theserverlabs.com/blog/2008/09/17/automated-integration-testing-with-selenium-maven-and-jetty/>blog
post (see [1] Jetty, selenium, and surefire plug-in configuration).
When running "mvn verify site", unit tests pass, then functional tests begin
executing and pass well, but in post-integration-test phase jetty stop goal
is executed and immediately after that selenium stop-server goal is run but
it fails with fatal error (see [2] Selenium stop-server "Connection reset"
error log. Because of this failure in default lifecycle before site/report
generation starts, build doesn't even get to run my new
cobertura-integration goal. Based on all given information, does anyone see
what could be the cause of this "connection reset" error? Is order of the
plug-ins correct, or should selenium server start/stop before jetty.
Then I tried running "mvn cobertura:cobertura-integration" on it's own, but
then another problem occurred - it seems jetty runs maven war plug-in and,
probably instructed by cobertura, tries to set war plug-in's
classesDirectory so that cobertura instrumented classes get used instead of
regular ones. Because classesDirectory is read-only property, maven war
plugin breaks the build (see [3] cobertura:cobertura-integration Maven log).
Build fails even if I configure jetty classesDirectory configuration element
to ${basedir}/target/generated-classes/cobertura. Does anyone know how to
overcome this? Some jetty configuration?
Regards,
Stevo.
[1] Jetty, selenium, and surefire plug-in configuration
...
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.0.0.pre5</version>
<configuration>
<scanIntervalSeconds>5</scanIntervalSeconds>
<stopPort>9966</stopPort>
<stopKey>foo</stopKey>
<connectors>
<connector
implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
<connector
implementation="org.mortbay.jetty.ssl.SslSelectChannelConnector">
<port>8443</port>
<maxIdleTime>60000</maxIdleTime>
<keystore>${basedir}/src/test/jetty/server.keystore</keystore>
<keyPassword>123456</keyPassword>
</connector>
</connectors>
<webAppConfig>
<contextPath>/mamp</contextPath>
</webAppConfig>
</configuration>
<dependencies>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-ssl</artifactId>
<version>7.0.0.pre5</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-exploded</goal>
</goals>
<configuration>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>1.0-rc-2-SNAPSHOT</version>
<executions>
<execution>
<id>start-selenium</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<background>true</background>
<logOutput>true</logOutput>
<multiWindow>true</multiWindow>
<firefoxProfileTemplate>${basedir}/src/test/selenium</firefoxProfileTemplate>
</configuration>
</execution>
<execution>
<id>stop-selenium</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-server</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<groups>functional</groups>
</configuration>
</execution>
</executions>
</plugin>
...
[2] Selenium stop-server "Connection reset" error log
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Connection reset
[INFO]
------------------------------------------------------------------------
[INFO] Trace
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:652)
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1064)
at java.net.URLConnection.getContent(URLConnection.java:688)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1392)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2587)
at
org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:178)
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:477)
at
org.codehaus.mojo.selenium.StopServerMojo.execute(StopServerMojo.groovy:66)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:540)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:519)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[3] cobertura:cobertura-integration Maven log
[INFO] [cobertura:cobertura-integration]
[INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Cobertura: Loaded information on 19 classes.
Report time: 282ms
[INFO] Cobertura Report generation was successful.
[INFO]
------------------------------------------------------------------------
[INFO] Building A Web Project
[INFO] task-segment: [cobertura:cobertura-integration]
[INFO]
------------------------------------------------------------------------
[INFO] Preparing cobertura:cobertura-integration
[INFO] [resources:resources]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 95 resources
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [cobertura:instrument]
[INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Cobertura: Loaded information on 175 classes.
Instrumenting 175 files to
D:\work\java\workspaces\projects\awebproject\target\generated-classes\cobertura
Cobertura: Saved information on 175 classes.
Instrument time: 579ms
[INFO] Instrumentation was successful.
[INFO] [resources:testResources]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Surefire report directory:
D:\work\java\workspaces\projects\awebproject\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.563 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Error configuring: org.apache.maven.plugins:maven-war-plugin. Reason:
ERROR: Cannot override read-only parameter: classesDirectory in goal:
war:war
[INFO]
------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error configuring:
org.apache.maven.plugins:maven-war-plugin. Reason: ERROR: Cannot override
read-only parameter: classesDirectory in goal: war:war
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:707)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:540)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkProjectLifecycle(DefaultLifecycleExecutor.java:1168)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkLifecycle(DefaultLifecycleExecutor.java:1009)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:627)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:553)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:523)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.PluginConfigurationException: Error
configuring: org.apache.maven.plugins:maven-war-plugin. Reason: ERROR:
Cannot override read-only parameter: classesDirectory in goal: war:war
at
org.apache.maven.plugin.DefaultPluginManager.validatePomConfiguration(DefaultPluginManager.java:1150)
at
org.apache.maven.plugin.DefaultPluginManager.getConfiguredMojo(DefaultPluginManager.java:698)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:461)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
... 20 more
On Thu, Mar 26, 2009 at 12:31 PM, Stevo Slavić <ss...@gmail.com> wrote:
> Hello maven users,
>
> Is there a way to activate a profile based on plug-in being run? I'm trying
> to find a workaround for issue present in both free open source code
> coverage maven report options, cobertura and emma (if there are more, please
> let me know). AFAIK, both, to produce report, run code instrumentalization,
> execute test phase in lifecycle separate from default, and then generate
> output. Problem is that test phase is so to speak hardcoded, so surefire
> execution configured to run in integration-test phase doesn't get run and
> coverage data will apear to be lower than what they actually are.
>
> Typicaly I use TestNG for tests, and it's test groups feature, separating
> tests in at least "unit", and "integration" and/or "functional" test groups.
> Then I configure surefire to run "unit" tests in "test" phase, and all the
> others in "integration-test" phase. If profile could be activated based on
> plug-in being run, workaround would be to create a profile, activeted on
> e.g. site plug-in being run, and in that profile surefire could be
> configured to contain only one default execution on test phase but would
> include all the tests.
>
> IMO, best solution would be to have following (in cobertura case,
> longstanding) issues fixed ( http://jira.codehaus.org/browse/MCOBERTURA-86,
> http://jira.codehaus.org/browse/MOJO-1299 )
>
> Regards,
> Stevo.
>