Hi guys,
I am building a Spring based Resful Api which is deployed on
Jetty.
I have tried a lot of combinations to get coverage for my
integration tests, but nothing has worked so far.
The command I am running is
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install
My pom config is shown below.
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.maven.plugin.version}</version>
<configuration>
<excludes>
</excludes>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.parent.build.directory}/jacoco.exec</destFile>
<excludes>
<exclude>**/*Test*</exclude>
</excludes>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.parent.build.directory}/jacoco.exec</dataFile>
<outputDirectory>${project.parent.reporting.outputDirectory}/jacoco</outputDirectory>
</configuration>
</execution>
<execution>
<id>prepare-agent-integration</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<destFile>${project.parent.build.directory}/jacoco-it.exec</destFile>
<excludes>
<exclude>**/*Test*</exclude>
</excludes>
<propertyName>jacoco.agent.itArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>verify</phase>
<goals>
<goal>report-integration</goal>
</goals>
<configuration>
<dataFile>${project.parent.build.directory}/jacoco-it.exec</dataFile>
<outputDirectory>${project.parent.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<includes>
<include>**/*Test*.class</include>
</includes>
<excludes>
<exclude>**/*IT</exclude>
</excludes>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<argLine>${surefireArgLine} -Xmx1024m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.failsafe.plugin.version}</version>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<argLine>${jacoco.agent.itArgLine} -Xmx1024m -XX:MaxPermSize=256m</argLine>
<skipTests>false</skipTests>
<includes>
<include>**/*IT.class</include>
</includes>
<systemPropertyVariables>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<goals>
<goal>set-system-properties</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<properties>
<property>
<name>logs.output</name>
<value>${project.parent.basedir}/Api/target/logs</value>
</property>
<property>
<name>logs.api.name</name>
<value>a-sample-api</value>
</property>
<property>
<name>logback.configurationFile</name>
<value>${project.parent.basedir}/Api-bundle/config/logback.xml</value>
</property>
<property>
<name>apibundle.dir</name>
<value>${project.parent.basedir}/Api-bundle</value>
</property>
<property>
<name>lib</name>
<value>${project.parent.basedir}/Api/target/dependency/lib</value>
</property>
<property>
<name>org.apache.cxf.Logger</name>
<value>org.apache.cxf.common.logging.Slf4jLogger</value>
</property>
<property>
<name>org.jboss.logging.provider</name>
<value>slf4j</value>
</property>
<property>
<name>org.eclipse.jetty.annotations.maxWait</name>
<value>120</value>
</property>
<property>
<name>application.properties</name>
<value>${project.parent.basedir}/Api-bundle/config/env/application-integrationtest.properties</value>
</property>
<property>
<name>sensitive.properties</name>
<value>${project.parent.basedir}/Api/src/test/resources/sensitive.properties</value>
</property>
<property>
<name>javax.net.ssl.trustStore</name>
<value>${project.parent.basedir}/Api-bundle/config/env/certs.jks</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<!-- Ensure context xml is set to significantly increase application
startup time -->
<contextXml>${project.parent.basedir}/Api/src/main/webapp/WEB-INF/jetty-web.xml</contextXml>
<!--
NOTE: To enable SSL locally make sure you the
following line below
${project.parent.basedir}/Api-bundle/config/env/jetty-https_ssl-dev.xml
-->
<jettyXml>${project.parent.basedir}/Api-bundle/config/jetty/jetty.xml,${project.parent.basedir}/Api-bundle/config/env/jetty-http-dev.xml</jettyXml>
<dumpOnStart>true</dumpOnStart>
<scanIntervalSeconds>0</scanIntervalSeconds>
<stopPort>${jetty.stop.port}</stopPort>
<stopKey>${jetty.stop.key}</stopKey>
<stopWait>10</stopWait>
<jvmArgs>${jacoco.agent.itArgLine}
-Dlib=${project.parent.basedir}/Api/target/dependency/lib
-Dlogback.configurationFile=${project.parent.basedir}/Api-bundle/config/jetty/logback.xml
-Dapplication.properties=${project.parent.basedir}/Api-bundle/config/env/application-integrationtest.properties</jvmArgs>
</configuration>
<dependencies>
<dependency>
<groupId>au.com.company.toolkit</groupId>
<artifactId>company-toolkit-logging-jetty</artifactId>
<version>${toolkit.logging.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-forked</goal>
</goals>
<configuration>
<daemon>true</daemon>
<waitForChild>true</waitForChild>
<maxStartupLines>1000</maxStartupLines>
</configuration>
</execution>
<!-- execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution-->
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
<configuration>
<stopWait>1</stopWait>
<stopPort>${jetty.stop.port}</stopPort>
<stopKey>${jetty.stop.key}</stopKey>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
- If I use the jetty *start* goal, my tests run and I get coverage for
the unit tests. But integration tests coverage is 0%.
- I changed it to *run-forked*, as recommended by a few posts, including
this
<http://stackoverflow.com/questions/33645713/jacoco-and-jetty-maven-plugin-gets-0-coverage>
But
I could not get it to work. As I launched the build, the server would not
even start and I was seeing this in the logs
[INFO] Webapp directory = C:\workspace\Api\src\main\webapp
[INFO] Quickstart generating
[INFO] Started
o.e.j.m.p.JettyWebAppContext@13137835{/,file:///C:/workspace/Api/src/main/webapp/,AVAILABLE}{file:///C:/workspace/Api/src/main/webapp/}
[INFO] Stopped
o.e.j.m.p.JettyWebAppContext@13137835{/,file:///C:/workspace/Api/src/main/webapp/,UNAVAILABLE}{file:///C:/workspace/Api/src/main/webapp/}
[INFO] Forked process starting
The whole of the logs were not visible, so I changed the property
*waitForChild* to *true, *and the end of the logs seemed to indicate
something but it was not an error.
[STDOUT] 13:52:24.872 [main] DEBUG
org.springframework.jndi.JndiLocatorDelegate - Converted JNDI name
[java:comp/env/spring.liveBeansView.mbeanDomain] not found - trying
original name [spring.liveBeansView.mbeanDomain].
javax.naming.NameNotFoundException; remaining name
'spring.liveBeansView.mbeanDomain'
[STDOUT] 13:52:24.872 [main] DEBUG org.springframework.jndi.JndiTemplate -
Looking up JNDI object with name [spring.liveBeansView.mbeanDomain]
[STDOUT] 13:52:24.872 [main] DEBUG
org.springframework.jndi.JndiPropertySource - JNDI lookup for name
[spring.liveBeansView.mbeanDomain] threw NamingException with message:
null. Returning null.
[STDOUT] 13:52:24.873 [main] DEBUG
org.springframework.core.env.PropertySourcesPropertyResolver - Could not
find key 'spring.liveBeansView.mbeanDomain' in any property source
I guess my questions are :
1. Can I get the coverage to work with jetty *start* goal?
2. What could help me investigate the issue I am facing with *run-forke*
d?
Thanks a lot for your time.
--
You received this message because you are subscribed to the Google Groups
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/c9d22a55-7dcc-4af9-afc6-bace65e9ba4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.