2014-10-27 31 views
0

當我使用「啓動TestRunner」在我的項目中運行所有測試時,我在SoapUI中更新項目屬性時遇到了一些問題。SoapUI:爲什麼當我使用Testrunner運行所有測試時項目屬性沒有更新

我有兩個TestSuites測試。所有的TestCases都有第一步 - groovy腳本。這個腳本在所有TestCases中都是一樣的:

Integer curIdAndKey = new Integer (testRunner.testCase.testSuite.project.getPropertyValue("IdAndKey")) 
Boolean curBool = new Boolean (testRunner.testCase.testSuite.project.getPropertyValue("bool")) 
Integer curTestsCount =new Integer(testRunner.testCase.testSuite.project.getPropertyValue("countOfTests")) 
if(curBool==false){ 
    curBool=true 
    curIdAndKey= curIdAndKey*curTestsCount 
} 
else { 
    curIdAndKey += 1 
} 

testRunner.testCase.setPropertyValue("aIdCase", curIdAndKey.toString()) 
testRunner.testCase.testSuite.project.setPropertyValue("bool", curBool.toString()) 
testRunner.testCase.testSuite.project.setPropertyValue("IdAndKey", curIdAndKey.toString()) 
log.info "Current Id : [$curIdAndKey]" 
log.info "Current bool : [$curBool]" 

而且我有一個項目屬性:「IdAndKey」和「bool」。 當我運行單個TestCase - 這個項目屬性正在更新,但是當我運行我所有的測試時,他們沒有更新(我看到更新只在日誌中,但沒有在屬性中)。 請幫幫我。

+0

已經在這裏得到解答:http://stackoverflow.com/q/26460598/3124333 – SiKing 2014-10-27 15:02:50

+0

不,這是不一樣的。我需要從SoapUI運行測試,而不是從命令行運行。 – 2014-10-27 17:41:11

+0

你說過:「推出TestRunner」。這使它一樣! – SiKing 2014-10-27 17:46:41

回答

0

啓動TestRunner窗口中的Basic選項卡下的一個選項是:「Save After」。選擇此選項並按啓動。您會注意到-S開關(在鏈接的重複帖子中討論)被添加到命令行中,該命令行顯示在下一個窗口中。

額外的討論,雖然過時,在official docs

+0

我的項目屬性IdAndKey鋼是相同的,它的變化只在日誌中可見,但測試後runnig值相同:( – 2014-10-29 15:10:05

+0

關閉並打開項目。 – SiKing 2014-10-29 15:15:13

+0

謝謝,它的工作,但有沒有其他方式沒有關閉和打開項目? – 2014-10-30 05:55:46

0

嘗試使用以下命令:

def globalProps = context.testRunner.testCase.testSuite.project; 
globalProps.setPropertyValue("aIdCase", curIdAndKey.toString()); 

讓我知道,如果它的工作原理。

+0

在我的情況下,它可以工作,我也使用一些全球道具,我將它們保存在項目中。 – 2015-11-26 12:58:36

相關問題