2014-03-12 44 views
3

SoapUI提供了一種通用語法來動態地在SOAP Request中插入屬性。在他們documentation他們解釋如何訪問不同的性能主要取決於財產範圍:SOAPUI - SOAPRequest - 擴展屬性以訪問當前TestStep的name屬性

#Project# - references a Project property 
#TestSuite# - references a TestSuite property in the containing TestSuite 
#TestCase# - references a TestCase property in the containing TestCase 
#MockService# - references a MockService property in the containing MockService 
#Global# - references a global property (optional) 
#System# - references a system property 
#Env# - references a environment variable 
[TestStep name]# - references a TestStep property within the current TestCase 

我的問題是我想訪問當前步步測試的名稱然而文件說,訪問一步步測試性能所需的名稱...還有另一種方式可以做到這一點?例如#TestCase#TestStep#Name。我知道如何用groovy腳本實現這一點,但在我的情況下,我想直接將屬性放在SOAP請求上。

在此先感謝

回答

3

最後我找到了解決辦法在documentation,用「=」前綴它可以指定一個Groovy腳本,並訪問一些上下文變量。在此背景下要求變量可用,並且也是其屬性,因此這有可能訪問當前步步測試名稱以:下面

${=request.name} 
+0

這是很好的,不知道這種簡單的方式來獲得測試步驟名。謝謝。 – Rao

0

實施方式是抓住從您的測試用例的請求,併到指定的值特定元素。

// get XMLHolder for request message def 
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context); 

// grabbing the specified request 
def holder = groovyUtils.getXmlHolder("Specified#Request") 

holder["//*:Password"] = 'password1'; 

對於上面的示例,您需要知道元素的Xpath。

請注意,這可以通過多種方式完成,但您通過groovy腳本指定了執行。它也可以通過#TestCase#屬性完成。例如:

<soapenv:Body> 
    <tns:AuthenticateUser> 
    <tns:Credentials> 
     <tns:IntegrationID>${IntegrationID}</tns:IntegrationID> 
     <tns:Username>${Username}</tns:Username> 
     <tns:Password>${Password}</tns:Password> 
    </tns:Credentials> 
    </tns:AuthenticateUser> 

+2

我知道如何使用groovy腳本訪問屬性並設置請求值,我被問到的是如何使用屬性擴展將TestStep名稱放入請求中。如果您在回答中指出$ {name}不起作用,那麼最後我用$ {= request.name}來完成。 – albciff