2014-09-25 66 views
0

我開發了一些SoapUI用例,它通過讀取文件中的屬性在每個測試用例的開始處設置一個屬性。這可以正常工作,然後我可以在每個測試請求步驟中通過語法${propertyA}訪問每個屬性(可以說propertyA)。soapui轉換測試套件屬性到使用腳本的測試用例

現在我意識到其中一個屬性對於每個測試用例都是相同的,所以我認爲我爲此創建了一個testsuite屬性並從測試用例屬性文件中刪除了屬性定義。首先我的測試案例都失敗了,因爲現在'propertyA'不再被瞭解,但我發現(根據http://www.soapui.org/Scripting-Properties/property-expansion.html)一種解決方案是將propertyA的每個引用替換爲#testSuite#propertyA

雖然這很乏味,但我想在每個測試用例的開頭都創建一個groovy腳本,它從測試套件屬性創建一個測試用例屬性。據 http://www.soapui.org/Scripting-Properties/tips-a-tricks.html我認爲像

def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue("propertyA") 
testRunner.testCase.setPropertyValue("propertyA", testSuiteProperty) 

腳本應該做的工作。如果我log.info的值爲testSuiteProperty這給出了確實的期望值,並且如果我將testCase屬性分配給某個變量並且log.info那麼它會顯示正確的值。

但是,在下一個測試步驟中,propertyA未知。只是爲了確保我嘗試在那裏使用${#testCase#propertyA},但那也是未知的。我在這裏弄錯了什麼?

回答

0

我認爲你的問題是中的的t必須大寫:${#TestCase#propertyA}。如果我添加一個常規測試步驟與您的代碼:

def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue("propertyA") 
testRunner.testCase.setPropertyValue("propertyA", testSuiteProperty) 

然後我添加了一個SOAP測試步驟與後續的xml:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:open="http://www.openuri.org/"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <open:procesa> 
     <open:selector>${#TestCase#propertyA}</open:selector> 
     </open:procesa> 
    </soapenv:Body> 
</soapenv:Envelope> 

它工作正常,但是如果我用${#testCase#propertyA}屬性值是未找到。

此外,您還可以檢查SOAP測試步驟請求左側的raw選項卡中是否使用了正確的值。在此選項卡中,將顯示請求,並將其屬性替換爲其值。

希望這會有所幫助,

相關問題