2

並列セレン テストを実行したいと思います (webriver と Spring JUnit ランナーを使用)。Webdriver は、カスタム スレッド スコープを持つ Spring Bean です。しかし、次の警告が表示SimpleThreadScope does not support descruction callbacksされるため、ブラウザは閉じられません。それらを閉じる方法はありますか (より正確には quit メソッドを呼び出します)?

春の設定

<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>

Maven構成

<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は、カスタム Thread 実装を提案しています。しかし、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();
        }
    }

}
4

1 に答える 1