2012-06-05 22 views
1

我是testng.i的新手,想在並行執行模式下運行測試。我正在使用 selenium grid, selenium webdriver, testng如何在testng.xml文件中的每個測試之間設置延遲

我的testng.xml文件是:

`<?xml version="1.0" encoding="UTF-8"?> 
<suite name="WebDriver Suite" verbose="1" parallel="tests" thread-count="5"> 
<test name="WebDriver Test" > 
    <parameter name="browser" value="firefox" /> 
    <parameter name="port" value="5555" /> 
<classes> 
    <class name="BootUpTest" > 
     <methods> 
      <include name = "testBootUp"/> 
     </methods> 
    </class> 
</classes> 
</test>  
<test name="WebDriver Test for IE" > 
    <parameter name="browser" value="chrome" /> 
    <parameter name="port" value="5556" /> 
<classes> 
    <class name="BootUpTest" > 
     <methods> 
      <include name = "testBootUp"/> 
     </methods> 
    </class> 
</classes> 
</test> 
</suite>` 
在上面的xml文件

我應該運行在firefoxtestBootUp方法以及chrome。我能夠運行上面的scenario.but我的範圍是我想要運行「webdriver的測試測試爲先,然後我需要IE測試,只有我webdriver的測試後,一些延遲應該有跑..

是有可能實現的是,在TestNG的.XML文件?。

+0

爲什麼你需要延遲? –

+0

'@ AJ'我設計了框架,當完成測試執行後,它將結果寫入Excel工作表中。在上述情況下,兩個測試同時運行,所以當打開一個測試並編輯表另一個測試時,在這種情況下,它顯示'IO異常'。 – Manigandan

+0

在這種情況下,我認爲拖延不會有所幫助。你會延遲多久?理想情況下,您應該等到第一種方法寫完。可能你應該看看如何將結果存儲在內存中並將其寫入測試套件的末尾? –

回答

1

你不能在testng.xml中做到這一點,但爲什麼不把sleep()放在以前的方法之一? (可能是@BeforeMethod)?

+0

感謝您的迴應cedric。但是,如果我把睡眠手段,我認爲它不會影響線程哪一個是並行的。 – Manigandan

+0

那麼,你的問題是「如何在testng.xml文件中的每個測試之間設置延遲」......如果排序是你正在嘗試完成的,你可能想要打開一個不同的問題。 –

相關問題