8
A
回答
12
是的,它是可能的。在groovy步驟中,您可以訪問testRunner,您可以使用它來訪問soapUI中的其他所有內容,並且在另一個測試用例中運行測試步驟。
所以,這個代碼是從上我的我的頭......
def tCase = testRunner.testCase.testSuite.project.testSuites["Name of the other test suite"].testCases["name of test case you want to access"]
或
def tCase = testRunner.testCase.testSuite.testCases["Name of test cases"]
def tStep = tCase.testSteps["test step you want to run"]
tStep.run(testRunner, context)
看看這個link它可能有一定的幫助......
1
我意識到我對派對有點遲到,但是我想我會通過發佈我的解決方案來解決類似問題來擴展這個話題。希望這有助於未來的人。解決方案可以擴展到覆蓋兩個以上的測試步驟,測試用例和/或項目。這也是我在這裏的第一篇文章,所以請提前原諒我的任何noob錯誤。不是最漂亮的解決方案。它可能有一些冗餘變量。所有代碼塊都包含整個解決方案。
問題:我想從兩個不同的測試步驟中獲取響應,每個測試步驟都在同一個工作區中的兩個差異項目中進行。得到它了?大!
SOLUTION:
變量的第一個項目
String firstProjName = "Generic Project One"
String firstProjTestSuiteName= "Generic Test Suite Name One"
String firstProjTestCaseName = "Generic Test Case Name One"
String firstProjTestStepName= "Generic Test Step Name One"
變量第二個項目
String secondProjName= "Generic Project Two"
String secondProjTestSuiteName = "Generic Test Suite Name Two"
String secondProjTestCaseName= "Generic Test Case Name Two"
String secondProjTestStepName= "Generic Test Step Name Two"
訪問通用測試步驟名稱一
def firstProj= null
def workspace = testRunner.testCase.testSuite.project.getWorkspace();
firstProj= workspace.getProjectByName(firstProjName)
def firstTestCase = firstProj.testSuites[firstProjTestSuiteName].testCases[firstProjTestCaseName ]
def firstTestStep = firstTestCase.getTestStepByName(firstProjTestStepName)
運行一般測試步驟名一個
def runner = null
runner = firstTestStep.run(testRunner, context)
def firstTestStepResp = runner.getResponseContent()
runner = null
打印響應登錄
log.info(firstTestStepResp)
同樣的事情第二測試步驟
def secondProj= null
secondProj= workspace.getProjectByName(secondProjName)
def secondTestCase = secondProj.testSuites[secondProjTestSuiteName ].testCases[secondProjTestCaseName]
def secondTestStep = secondTestCase.getTestStepByName(secondProjTestStepName)
runner = secondTestStep.run(testRunner, context)
def secondTestStepResp = runner.getResponseContent()
log.info(secondTestStepResp)
我們現在有機會獲得兩種反應爲字符串不管我們想要什麼,我們都可以玩。比較,標記等。還有
getResponseContentAsXml()
如果響應是希望作爲xml而不是字符串。
3
對於我們這些像我一樣正在尋找當前版本的Ready!API
def testStep = testRunner.testCase.testSuite.project.getTestSuiteByName("[OTHER_TEST_SUITE_NAME]").getTestCaseByName("[OTHER_TEST_CASE_NAME]").getTestStepByName("[OTHER_TEST_STEP_NAME]")
testStep.run(testRunner, context)
相關問題
- 1. 貝哈特從測試步驟
- 2. 查詢TFS2010測試用例無步驟
- 3. 如何在SoapUi中使用Groovy重命名測試用例或測試步驟
- 4. 如何導出測試案例與測試步驟從集會?
- 5. 測試時做出步驟
- 6. 如何在java中運行soapUi的特定測試步驟
- 7. SoapUI Groovy Script,log.info有關測試步驟運行的詳細信息。
- 8. 使用Junit進行多步驟測試
- 9. SoapUI Groovy:檢查測試步驟是否是肥皂請求
- 10. TFS 2015:將測試步驟添加到測試案例
- 11. Specflow中的繼承測試步驟導致模糊步驟
- 12. 在測試步驟定義中定義外化的groovy文件
- 13. 如何使用groovy腳本在SoapUI中執行特定的測試步驟
- 14. Spring-Batch:測試步驟作用域步驟
- 15. 如何測試步驟跟蹤器
- 16. 如何使用soapUI中的groovy刪除測試步驟
- 17. 每次測試的測試設置和拆卸步驟
- 18. 如何測試Spring Batch中的單個步驟而不運行其他?
- 19. 如何測試服務功能需要運行的步驟?
- 20. 使用Groovy腳本循環遍歷SOAP UI中的所有測試用例和測試步驟
- 21. 如何使用Groovy測試步驟在soapUI中設置Cookie?
- 22. 黃瓜PendingExceprion測試步驟在Intellij IDEA
- 23. 是否有測試版的步驟,然後這個循環
- 24. 使用python閱讀Quality Center的特定測試步驟
- 25. 在azure中創建多步驟測試時出現錯誤應用程序洞察力多步驟測試
- 26. 在OSX上運行NUnit測試的步驟
- 27. 通過groovy在SOAPUI中跳過測試步驟
- 28. 測試未定義的步驟未標記爲失敗的測試
- 29. phpunit中登錄認證測試用例的步驟laravel
- 30. 我們如何添加SOAP請求使用groovy腳本測試案例中的測試步驟