我正在尝试并行运行黄瓜测试。目前,它们按顺序运行,并且运行所有测试要花费大量的时间。
这是我当前的pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Salesforce</groupId>
<artifactId>Salesforce</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>Cucumber</module>
</modules>
<properties>
<maven.repo.url.releases>http://maven-repo2.iggroup.local:8081/nexus/content/repositories/ig.release
</maven.repo.url.releases>
<maven.repo.url.snapshots>http://maven-repo2.iggroup.local:8081/nexus/content/repositories/ig.snapshot
</maven.repo.url.snapshots>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<cucumber.version>4.2.6</cucumber.version>
<junit.version>4.12</junit.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.mail/javax.mail-api -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.6.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.mail/javax.mail -->
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>com.googlecode.java-diff-utils</groupId>
<artifactId>diffutils</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.selenium</groupId>
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
<version>1.0.17</version>
<configuration>
<!-- root directory that downloaded driver binaries will be stored in -->
<rootStandaloneServerDirectory>./target/webdrivers</rootStandaloneServerDirectory>
<!-- Where you want to store downloaded zip files -->
<downloadedZipFileDirectory>./target/webdrivers</downloadedZipFileDirectory>
<!-- Location of a custom repository map -->
<customRepositoryMap>${project.basedir}/CustomRepositoryMap.xml</customRepositoryMap>
<!-- This will ensure that the plugin only downloads binaries for the current OS, this will override anything specified in the <operatingSystems> configuration -->
<onlyGetDriversForHostOperatingSystem>false</onlyGetDriversForHostOperatingSystem>
<!-- If set to false will download every version available (Other filters will be taken into account -->
<onlyGetLatestVersions>false</onlyGetLatestVersions>
<!-- Operating systems you want to download binaries for (Only valid options are: windows, linux, osx) -->
<operatingSystems>
<windows>false</windows>
<linux>true</linux>
<mac>false</mac>
</operatingSystems>
<!-- Provide a list of drivers and binary versions to download (this is a map so only one version can be specified per driver) -->
<getSpecificExecutableVersions>
<googlechrome>LATEST</googlechrome>
</getSpecificExecutableVersions>
<!-- Download 32bit binaries -->
<!--<thirtyTwoBitBinaries>false</thirtyTwoBitBinaries>-->
<!-- Download 64bit binaries -->
<!--<sixtyFourBitBinaries>true</sixtyFourBitBinaries>-->
</configuration>
<executions>
<execution>
<id>driverdownload</id>
<goals>
<goal>selenium</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- FOR PARALLELISM: -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<!-- UNCOMMENT - To add any exclusions if required -->
<!-- <excludes> <exclude>**/*IT*.java</exclude> </excludes> -->
<includes>
<!-- UNCOMMENT BELOW LINE - To execute feature files with a single
runner -->
<include>**/Default.java</include>
<!-- UNCOMMENT BELOW LINE - To execute feature files with multiple
runners -->
<!-- <include>**/*Runner.java</include> -->
</includes>
<!-- UNCOMMENT BELOW 3 LINES - To execute using parallel or combination
option -->
<parallel>methods</parallel>
<threadCount>2</threadCount>
<perCoreThreadCount>true</perCoreThreadCount>
<!-- UNCOMMENT BELOW 3 LINES - To execute using forking or combination
option -->
<!-- <forkCount>2</forkCount>
<reuseForks>true</reuseForks>
<reportsDirectory>${project.build.directory}/failsafe-reports_${surefire.forkNumber}</reportsDirectory> -->
</configuration>
</execution>
</executions>
</plugin>
<!-- Used for reporting the output: -->
<!-- <plugin>-->
<!-- <groupId>com.trivago.rta</groupId>-->
<!-- <artifactId>cluecumber-report-plugin</artifactId>-->
<!-- <version>1.7.2</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>report</id>-->
<!-- <phase>post-integration-test</phase>-->
<!-- <goals>-->
<!-- <goal>reporting</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- <configuration>-->
<!-- <sourceJsonReportDirectory>${project.build.directory}/json-cucumber-reports</sourceJsonReportDirectory>-->
<!-- <generatedHtmlReportDirectory>${project.build.directory}/generated-report</generatedHtmlReportDirectory>-->
<!-- <expandStepHooks>true</expandStepHooks>-->
<!-- </configuration>-->
<!-- </plugin>-->
</plugins>
<testSourceDirectory>src/test/java/runner</testSourceDirectory>
<testResources>
<testResource>
<directory>src/test/resources/UAT_Regression
</directory>
</testResource>
</testResources>
</build>
<repositories>
<!-- Sonatype OSS -->
<repository>
<id>sonatype</id>
<name>Day CQ5 Repository (OSGI)</name>
<url>http://maven-repo2.iggroup.local:8081/nexus/content/repositories/sonatype-oss</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- Central mirror -->
<repository>
<id>central</id>
<name>Day CQ5 Repository (OSGI)</name>
<url>http://maven-repo2.iggroup.local:8081/nexus/content/repositories/central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>atlassian-repo</id>
<name>Day CQ5 Repository (OSGI)</name>
<url>http://maven-repo2.iggroup.local:8081/nexus/content/repositories/atlassian.public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
<id>central</id>
<url>http://maven-repo2.iggroup.local:8081/nexus/content/repositories/central</url>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
</dependencyManagement>
<distributionManagement>
<repository>
<id>ig.releases</id>
<name>ig-repository</name>
<url>${maven.repo.url.releases}</url>
</repository>
<snapshotRepository>
<id>ig.snapshots</id>
<name>ig-repository</name>
<url>${maven.repo.url.snapshots}</url>
</snapshotRepository>
</distributionManagement>
</project>
我的项目目录几乎包含:src/main/java/com/automation/cucumber
,该目录包含2个文件夹;步骤(包含步骤定义)和utils(帮助器方法)。
在src/main/test/resources/UAT_Regression
下,我的.feature
文件在这里。
我的跑步者班级位于:
src/test/java/runner/runner/RunCucumberIT.java
上面的pom被编码为反映此repository中的内容,因为它具有并行运行的黄瓜测试的示例。
但是,当我尝试运行我的跑步者类时,它几乎是按顺序运行,而不是并行运行,所以不知道为什么。谁能指出我的错误?
我在测试中使用的是WebDriver。