Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Excerpt
hiddentrue
In this post I'll explain how you can use the new ConsoleRunner to execute CWB tests in parallel and have failed tests automatically retried. This aids you in running tests faster and can be especially helpful when suffering from random failing SAHI tests.

Warning

The most up-to-date information about the ConsoleRunner can be found in the reference documentation.

 

With the latest update of Cucumber Web Bridge we added the ConsoleRunner class.  It is meant to execute a batch of tests from the command line, and offers an alternative to cucumber.api.cli.Main for running cucumber features.

...

Code Block
languagexml
titleMinimal configuration of ConsoleRunner in Maven pom
<build>
   	<plugins>
    	<plugin>
         	<artifactId>maven-antrun-plugin</artifactId>
         	<version>1.7</version>
         	<executions>
            	<execution>
               		<phase>integration-test</phase>
               		<configuration>
                  		<tasks><target>
					 		<java classname="com.foreach.cuke.core.cli.ConsoleRunner" fork="yes" failonerror="true">
					   			<classpath refid="maven.test.classpath"/>
						   		<sysproperty key="file.encoding" value="UTF-8"/>
						   		<arg line="--output ${project.build.directory}/cucumber-results"/>
						   		<arg line="--threads 3"/>
						   		<arg line="--retries 1"/>
						   		<arg line="--glue com.foreach.cuke"/>
						   	   	<arg line="--tags ~@ignore"/>
								<arg line="${project.basedir}/src/test/resources/features"/>
							</java>
						</tasks>target>
					</configuration>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

...

Section
Column
Code Block
languagexml
titlepom.xml excerpt using Cucumber Main class
 <plugin>
   <artifactId>maven-antrun-plugin</artifactId>
   <version>1.7</version>
   <executions>
      <execution>
         <phase>integration-test</phase>
         <configuration>
            <tasks><target>
               <java classname="cucumber.api.cli.Main" fork="yes">
                  <sysproperty key="file.encoding" value="UTF-8"/>
                  <sysproperty key="environment" value="${environment}"/>
                  <sysproperty key="browser" value="${browser}"/>
                  <sysproperty key="nopause" value="${nopause}"/>
                  <sysproperty key="highlight" value="${highlight}"/>
                  <classpath refid="maven.test.classpath"/>
                  <arg line="--format com.foreach.cuke.core.formatter.ConsoleReporter"/>
                  <arg line="--format html:${project.build.directory}/cucumber/${report.output.dir}/plain-html-reports"/>
                  <arg line="--format junit:${project.build.directory}/cucumber/${report.output.dir}/cucumber-report.xml"/>
                  <arg line="--format json:${project.build.directory}/cucumber/${report.output.dir}/cucumber-report.json"/>
                  <arg line="--glue com.foreach.cuke"/>
                  <arg line="--glue mypackage"/>
                  <arg line="--tags ~@ignore"/>
                  <arg line="--tags ${tags}"/>
                  <arg line="${project.basedir}/features/${features}/"/>
               </java>
            </tasks>target>
         </configuration>
         <goals>
            <goal>run</goal>
         </goals>
      </execution>
   </executions>
</plugin>
<plugin>
   <groupId>net.masterthought</groupId>
   <artifactId>maven-cucumber-reporting</artifactId>
   <version>0.0.4</version>
   <executions>
      <execution>
         <id>cucumber-reports</id>
         <phase>integration-test</phase>
         <goals>
            <goal>generate</goal>
         </goals>
         <configuration>
            <projectName>${project.name}</projectName>
            <outputDirectory>
               ${project.build.directory}/cucumber/${report.output.dir}/pretty-html-reports
            </outputDirectory>
            <cucumberOutput>
               ${project.build.directory}/cucumber/${report.output.dir}/cucumber-report.json
            </cucumberOutput>
            <enableFlashCharts>true</enableFlashCharts>
         </configuration>
      </execution>
   </executions>
</plugin>
Column
Code Block
languagexml
titlesame configuration using ConsoleRunner
 <plugin>
   <artifactId>maven-antrun-plugin</artifactId>
   <version>1.7</version>
   <executions>
      <execution>
         <phase>integration-test</phase>
         <configuration>
            <tasks><target>
               <java classname="com.foreach.cuke.core.cli.ConsoleRunner" fork="yes" failonerror="true">
                  <classpath refid="maven.test.classpath"/>
     			  <sysproperty key="file.encoding" value="UTF-8"/>
                  <arg line="--output ${project.build.directory}/cucumber/"/>
                  <arg line="--threads 1"/>
                  <arg line="--retries 0"/>
                  <arg line="--glue com.foreach.cuke"/>
				  <arg line="--glue mypackage"/>
                  <arg line="--tags ~@ignore"/>
			      <arg line="--tags ${tags}"/>
                  <arg line="-P browser=${browser}"/>
				  <arg line="-P highlight=${highlight}"/>
				  <arg line="-P environment=${environment}"/>
                  <arg line="${project.basedir}/src/test/resources/features"/>
               </java>
            </tasks>target>
         </configuration>
         <goals>
            <goal>run</goal>
         </goals>
      </execution>
   </executions>
</plugin>

...