我的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
看起来黄瓜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。或者是否有另一种同时在2个浏览器上运行测试的方法?提前感谢您的帮助。
答案 0 :(得分:0)
不确定与Bean相关的错误,但可能还会在测试级别传递'Parallel'和'Thread-count'标签[请参见下文]会在Parallel中触发两个浏览器。
<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>
....等等...