我正在尝试设置宁静黄瓜测试以并行运行
我已经添加了已经提到的所有必要配置,但是由于某些原因,测试在单个线程中执行。我用forkCount,threadCount,parallel,useUnlimitedThreadCounts等尝试了各种组合,但似乎没有任何效果。
还尝试了对JUnit 4和5的依赖,但也无法正常工作。
Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
<serenity.version>2.2.5</serenity.version>
<serenity.maven.version>2.2.5</serenity.maven.version>
<serenity.cucumber5.version>2.2.2</serenity.cucumber5.version>
<cucumber.version>5.6.0</cucumber.version>
<selenium.version>3.141.59</selenium.version>
</properties>
<dependencies>
<!-- Cucumber -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</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>
<!-- Serenity -->
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
<exclusions>
<exclusion>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber5</artifactId>
<version>${serenity.cucumber5.version}</version>
</dependency>
<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M4</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M4</version>
</dependency>
</dependencies>
<configuration>
<parallel>classes</parallel>
<threadCount>2</threadCount>
<forkCount>2C</forkCount>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
用于验证的Maven调试日志表明出于某些原因,parallelMavenExecution设置为false。
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-failsafe-plugin:3.0.0-M4:integration-test from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-failsafe-plugin:3.0.0-M4, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@4f8e5cde]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-failsafe-plugin:3.0.0-M4:integration-test' with basic configurator -->
[DEBUG] (s) additionalClasspathElements = []
[DEBUG] (s) basedir = /Users/vinothraj/IdeaProjects/hiscox-usa-portal-testsuite
[DEBUG] (s) childDelegation = false
[DEBUG] (s) classpathDependencyExcludes = []
[DEBUG] (s) defaultClassesDirectory = /target/classes
[DEBUG] (s) dependenciesToScan = []
[DEBUG] (s) disableXmlReport = false
[DEBUG] (s) enableAssertions = true
[DEBUG] (f) excludedEnvironmentVariables = []
[DEBUG] (f) forkCount = 2C
[DEBUG] (s) forkMode = once
[DEBUG] (s) forkedProcessExitTimeoutInSeconds = 30
[DEBUG] (s) junitArtifactName = junit:junit
[DEBUG] (s) localRepository = id: local
url: file:///.m2/repository/
layout: default
snapshots: [enabled => true, update => always]
releases: [enabled => true, update => always]
[DEBUG] (s) parallel = classes
[DEBUG] (f) parallelMavenExecution = false
[DEBUG] (s) parallelOptimized = true
[DEBUG] (s) perCoreThreadCount = true
提前感谢。
https://github.com/cucumber/cucumber-jvm/tree/master/junit
黄瓜JUnit支持跨多个线程并行执行功能文件。要使用maven启用此功能,请将parallel属性设置为方法之一或两者都设置。
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<!-- Use 2.22.1 or higher -->
<version>${maven-surefire-plugin.version}</version>
<configuration>
<parallel>both</parallel>
<threadCount>4</threadCount>
</configuration>
</plugin>
</plugins>
</build>