并行执行 Cucumber 特征文件
问题: 需要并行执行多个 Cucumber 特征文件,每个特征文件与不同的标签相关联,将特定文件分配给特定浏览器。
解决方案:
利用开源cucumber-jvm-parallel-plugin提供了一个功能-用于并行黄瓜测试执行的丰富解决方案。
- 插件配置:
将以下插件配置添加到项目的 Maven pom 文件中:
<code class="xml"><dependency> <groupid>com.github.temyers</groupid> <artifactid>cucumber-jvm-parallel-plugin</artifactid> <version>2.1.0</version> </dependency> <plugin> <groupid>com.github.temyers</groupid> <artifactid>cucumber-jvm-parallel-plugin</artifactid> <version>2.1.0</version> <executions> <execution> <id>generateRunners</id> <phase>generate-test-sources</phase> <goals> <goal>generateRunners</goal> </goals> <configuration> <glue>foo, bar</glue> <outputdirectory>${project.build.directory}/generated-test-sources/cucumber</outputdirectory> <featuresdirectory>src/test/resources/features/</featuresdirectory> <cucumberoutputdir>target/cucumber-parallel</cucumberoutputdir> <format>json</format> <strict>truetrue</strict> <tags>@chrome,@firefox</tags> <filterfeaturesbytags>false</filterfeaturesbytags> <usetestng>false</usetestng> <namingscheme>simple</namingscheme> <parallelscheme>SCENARIO</parallelscheme> </configuration> </execution> </executions> </plugin></code>
- 添加第二个插件:
添加另一个插件,该插件将调用上一个插件生成的运行器类:
<code class="xml"><plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.19</version> <configuration> <forkcount>5</forkcount> <reuseforks>true</reuseforks> <includes> <include>**/*IT.class</include> </includes> </configuration> </plugin></code>
共享 WebDriver 类:
实现共享 WebDriver 类:
<code class="java">public class SharedDriver extends EventFiringWebDriver { // Singleton WebDriver instance private static WebDriver REAL_DRIVER = null; // Closing hook for WebDriver private static final Thread CLOSE_THREAD = new Thread() { @Override public void run() { REAL_DRIVER.close(); } }; // WebDriver setup static { Runtime.getRuntime().addShutdownHook(CLOSE_THREAD); } public SharedDriver() { super(CreateDriver()); } public static WebDriver CreateDriver() { if (REAL_DRIVER == null) REAL_DRIVER = new FirefoxDriver(); setWebDriver(REAL_DRIVER); return REAL_DRIVER; } public static void setWebDriver(WebDriver webDriver) { SharedDriver.REAL_DRIVER = webDriver; } public static WebDriver getWebDriver() { return SharedDriver.REAL_DRIVER; } // Disable closing for shared driver @Override public void close() { if (Thread.currentThread() != CLOSE_THREAD) { throw new UnsupportedOperationException("Closing is handled by shutdown hook."); } super.close(); } }</code>
注意事项:
- fork 计数(并行线程)的数量应与可用硬件资源和注册节点保持一致。
- Grid Hub 必须以 -DPOOL_MAX=512 或更高级别启动才能执行大量(>50)线程并行。
以上是如何在不同浏览器和标签下并行执行Cucumber特征文件?的详细内容。更多信息请关注PHP中文网其他相关文章!

JVM'SperformanceIsCompetitiveWithOtherRuntimes,operingabalanceOfspeed,安全性和生产性。1)JVMUSESJITCOMPILATIONFORDYNAMICOPTIMIZAIZATIONS.2)c提供NativePernativePerformanceButlanceButlactsjvm'ssafetyFeatures.3)

JavaachievesPlatFormIndependencEthroughTheJavavIrtualMachine(JVM),允许CodeTorunonAnyPlatFormWithAjvm.1)codeisscompiledIntobytecode,notmachine-specificodificcode.2)bytecodeisisteredbytheybytheybytheybythejvm,enablingcross-platerssectectectectectross-eenablingcrossectectectectectection.2)

TheJVMisanabstractcomputingmachinecrucialforrunningJavaprogramsduetoitsplatform-independentarchitecture.Itincludes:1)ClassLoaderforloadingclasses,2)RuntimeDataAreafordatastorage,3)ExecutionEnginewithInterpreter,JITCompiler,andGarbageCollectorforbytec

JVMhasacloserelationshipwiththeOSasittranslatesJavabytecodeintomachine-specificinstructions,managesmemory,andhandlesgarbagecollection.ThisrelationshipallowsJavatorunonvariousOSenvironments,butitalsopresentschallengeslikedifferentJVMbehaviorsandOS-spe

Java实现“一次编写,到处运行”通过编译成字节码并在Java虚拟机(JVM)上运行。1)编写Java代码并编译成字节码。2)字节码在任何安装了JVM的平台上运行。3)使用Java原生接口(JNI)处理平台特定功能。尽管存在挑战,如JVM一致性和平台特定库的使用,但WORA大大提高了开发效率和部署灵活性。

JavaachievesPlatFormIndependencethroughTheJavavIrtualMachine(JVM),允许Codetorunondifferentoperatingsystemsswithoutmodification.thejvmcompilesjavacodeintoplatform-interploplatform-interpectentbybyteentbytybyteentbybytecode,whatittheninternterninterpretsandectectececutesoneonthepecificos,atrafficteyos,Afferctinginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginging

JavaispoperfulduetoitsplatFormitiondence,对象与偏见,RichstandardLibrary,PerformanceCapabilities和StrongsecurityFeatures.1)Platform-dimplighandependectionceallowsenceallowsenceallowsenceallowsencationSapplicationStornanyDevicesupportingJava.2)

Java的顶级功能包括:1)面向对象编程,支持多态性,提升代码的灵活性和可维护性;2)异常处理机制,通过try-catch-finally块提高代码的鲁棒性;3)垃圾回收,简化内存管理;4)泛型,增强类型安全性;5)ambda表达式和函数式编程,使代码更简洁和表达性强;6)丰富的标准库,提供优化过的数据结构和算法。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

SublimeText3 Linux新版
SublimeText3 Linux最新版

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。