2
我想运行并行的硒测试(使用webriver和Spring JUnit亚军)。 Webdriver是一个具有自定义线程范围的spring bean。但是,我收到以下警告SimpleThreadScope does not support descruction callbacks
因此浏览器未关闭。任何想法如何关闭他们(更确切地说是调用quit方法)?Spring SimpleThreadScope不支持描述回调
Spring配置
<bean id="threadScope" class="org.springframework.context.support.SimpleThreadScope" />
<bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
<property name="scopes">
<map>
<entry key="thread" value-ref="threadScope" />
</map>
</property>
</bean>
<bean id="webDriver" class="org.openqa.selenium.remote.RemoteWebDriver" scope="thread" destroy-method="quit">
<constructor-arg name="remoteAddress" value="http://localhost:4444/wd/hub" />
<constructor-arg name="desiredCapabilities" ref="browserAgent" />
</bean>
行家配置
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<configuration>
<includes>
<include>**/*Test.class</include>
</includes>
<reportsDirectory>${basedir}/target/surefire-reports</reportsDirectory>
<parallel>classes</parallel>
<threadCount>2</threadCount>
<perCoreThreadCount>false</perCoreThreadCount>
</configuration>
</plugin>
这篇文章http://www.springbyexample.org/examples/custom-thread-scope-module-code-example.html表明自定义线程的实现。但是,使用任何JUnit运行器的Runnable的扩展点类型在哪里?
public class ThreadScopeRunnable implements Runnable {
protected Runnable target = null;
/**
* Constructor
*/
public ThreadScopeRunnable(Runnable target) {
this.target = target;
}
/**
* Runs <code>Runnable</code> target and
* then afterword processes thread scope
* destruction callbacks.
*/
public final void run() {
try {
target.run();
} finally {
ThreadScopeContextHolder.currentThreadScopeAttributes().clear();
}
}
}
不错 - 很高兴知道我不是唯一试图从JUnit运行Selenium的人。此外,也可能从多个webdrivers运行。 – ManRow