Cucumber Pom example?

357 views
Skip to first unread message

barry.c...@barcap.com

unread,
May 25, 2016, 1:25:33 AM5/25/16
to JaCoCo and EclEmma Users
Hi

I've been trying to configure Jacoco with cucumber tests initiated via Maven.

When I run the build it fails with a 'multiple tests running in parallel within the same jvm' error

I've played about with all the fork properties to no avail.

Has anyone got an example Pom that works?

pa...@kuruma.co.uk

unread,
Jun 2, 2016, 5:54:28 AM6/2/16
to JaCoCo and EclEmma Users, barry.c...@barcap.com

Hi Barry,

To get cucumber working you dont really need to do much with the pom file at all except include the dependencies, and set up the failsafe plugin and jacoco plugin for coverage in the usual way.

<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-spring</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${failsafe.version}</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Sets the jacoco VM argument line used when integration tests are
run. -->
<argLine>${failsafeArgLine}</argLine>

<!-- Skips integration tests if the value of skip.integration.tests
property is true -->
<skipTests>${skip.integration.tests}</skipTests>

<!-- Set the path to the phantom js binary file which is used to act
as a headless browser when running selenium driven integration tests: See
setPhantomJSDriver() method in GeneralIT.java -->
<systemPropertyVariables>
<phantomjs.binary>${phantomjs.binary}</phantomjs.binary>
</systemPropertyVariables>
<includes>
<include>**/*IT*</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<!-- Prepares the property pointing to the JaCoCo runtime agent which
is passed as VM argument when the Maven Failsafe plugin is executed. Prepare
agent is by default bound to the maven default life cycle initialize phase -->
<execution>
<id>pre-integration-test</id>
<!-- Binds to initialize phase by default -->
<phase>initialize</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<destFile>${jacoco-IT-test-exec-path}</destFile>
<includes>
<include>uk/co/**</include>
</includes>
<!-- Seems to ignore this now -->
<excludes>
<exclude>**/*IT*</exclude>
<exclude>uk/co/netart/config/*</exclude>
<exclude></exclude>
</excludes>
<!-- Sets the name of the property containing the settings for JaCoCo
runtime agent. This is so the failsafe plugin knows where the IT jacoco exec
file is. -->
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
<!-- By default the jacoco:report goal is bound to the verify phase
of the default life cycle -->
<execution>
<id>post-integration-test</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>${jacoco-IT-test-exec-path}</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>${jacoco-IT-test-report-directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

Sorry about the comments but you can just remove them.

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages