gpt4 book ai didi

java - 并行 TestNG - cucumber.runtime.CucumberException : No qualifying bean of type 'com.hooks.CustomHook' available

转载 作者:太空宇宙 更新时间:2023-11-04 10:39:05 25 4
gpt4 key购买 nike

我的 testng.xml 像这样:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="BDD Test Suite" verbose="1" parallel="tests" thread-count="1" configfailurepolicy="continue">
<test name="Test 1" annotations="JDK" preserve-order="true">
<parameter name="browser" value="Chrome" />
<classes>
<class name="CukesTestRunner"/>
</classes>
</test>
<test name="Test 2" annotations="JDK" preserve-order="true">
<parameter name="browser" value="Firefox" />
<classes>
<class name="CukesTestRunner"/>
</classes>
</test>
</suite>

当thread-count=“1”时,它运行良好,因此它在Chrome和Firefox上依次运行相同的测试。但是当切换到 2 个线程数时,为了在 2 个浏览器上同时运行它们,我遇到了这个错误:

cucumber.runtime.CucumberException: No qualifying bean of type 'com.hooks.CustomHook' available: expected single matching bean but found 1: com.hooks.CustomHook

看起来 cucumber glue不再适用于多线程。它的接线方式如下:

@RunWith(Cucumber.class)
@CucumberOptions(
features = "classpath:features",
plugin = { "pretty", "html:target/cucumber-html-report" , "json:target/cucumber-reports/CucumberTestReport.json"},
glue = { "com.hooks", "com.stepdef" },
tags = {"@run"}
)
public class CukesTestRunner {
...

我的猜测是一个头已经接受了它,所以另一个提示,但我不确定是否缺少任何配置来并行运行 TestNG。或者是否有另一种方法可以同时在两个浏览器上运行测试?预先感谢您提供的任何帮助。

最佳答案

不确定您的 Bean 相关错误,但可能在测试级别传递“并行”和“线程计数”标签[见下文]将触发并行的两个浏览器..

<test name= "My Regression-Test1" parallel="classes" thread-count="2">
<classes>
<class name="com.abb.www.grid.runnerClasses1"/>
<class name="com.abb.www.grid.runnerClasses2"/>
</classes>
</test>

...等等...

关于java - 并行 TestNG - cucumber.runtime.CucumberException : No qualifying bean of type 'com.hooks.CustomHook' available,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49205081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com