私は、40のWebdriverテストを2つのグループに分けています.1つはシリアルで実行する必要があります(それぞれにはメタデータグループタグ "crm_import"があります)。これら二つのグループは、次のXMLファイルによって参照されていますMavenコマンドラインからTestNGを使用して複数のsuiteXmlFileを実行しているときに、Webdriverブラウザウィンドウが閉じないのはなぜですか?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.8</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
<suiteXmlFile>testng-includeOnly.xml</suiteXmlFile>
</suiteXmlFiles>
...
</configuration>
を私はスキームを得るときジェンキンスの中からそれらを実行する必要があるため、次のように
TestNG.xml
<suite name = "Suite" thread-count="2" parallel="methods">
<test name = "TestSet">
<groups>
<run>
<exclude name = "crm_import"/>
</run>
</groups>
<classes>
<class name = "com.dcp.test.suite.TestSuite"/>
</classes>
</test>
</suite>
TestNG_includeOnly.xml
<suite name = "Suite2" verbose="1" >
<test name = "TestSet">
<groups>
<run>
<include name = "crm_import"/>
</run>
</groups>
<classes>
<class name = "com.dcp.test.suite.TestSuite"/>
</classes>
</test>
</suite>
これら二つはPOMファイル内で参照されています
mvn clean test -DsuiteXmlFile=testng.xml site
2つの問題が発生...
:作業、私はちょうど並行セットを実行しようとする、以下のものを使用して、それらを実行するためのコマンドラインバージョンを使用しています40回のテストを実行すると- は、それは私がPOMファイルに移動し、1つのスイートまたはその他をコメントアウトするだけで実行した場合38個のウィンドウが
開いたままにされ、両方のセット
mvn clean test site
...すべての問題はありません。ウィンドウは開いておらず、並列テストは並行して実行されます。
あなたは私が開くか疑問やブラウザを閉じている場合は、ここでTestSuite.javaファイルが延びていることを、基本クラスのスケルトンだ...あなたはどこになど興味が場合
public class TestSuiteBase implements IInvokedMethodListener {
...
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
if (method.isTestMethod()) {
System.setProperty("webdriver.firefox.marionette", "/opt/geckodriver");
ProfilesIni profile = new ProfilesIni();
String ffProfileName = properties.getProperty("ffProfileName");
FirefoxProfile myprofile = profile.getProfile(ffProfileName);
System.out.println("--> creating WebDriver instance..." + "Thread id = " + Thread.currentThread().getId());
WebDriver driver = new FirefoxDriver(myprofile);
LocalDriverManager.setWebDriver(driver);
}
}
@Override
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
if (method.isTestMethod()) {
WebDriver driver = LocalDriverManager.getDriver();
if (driver != null) {
System.out.println("After Test breakdown, quitting driver..." + "Thread id = " + Thread.currentThread().getId());
driver.quit();
}
}
}
あなたはその後、必要がある私は、そのアーキテクチャの一部を得た私はここからそれを借りあなたが複数のTestNGのスイートに渡すを見ているとしたら...あなたが共有https://rationaleemotions.wordpress.com/2013/07/31/parallel-webdriver-executions-using-testng/
'@ AfterGroup'、' @ AfterTest'などのものはどうでしょうか? ?リスナーの代わりに? – khmarbaise
私は以前にそのような構造を使用していましたが、一方のスイートの並列処理を実装するためにリスナー方式に切り替えました。 –
テストを実行すると、afterInvocation()メソッドのdebugステートメントが表示されるので、呼び出されていないようではないので、変更のメリットがわかりません。 –