2013-07-22 217 views
2

我有名稱爲FirstTestSuite的測試套件,然後創建了一個名爲FirstTestCase的測試案例。我在肥皂UI編寫Groovy腳本是這樣的:使用groovy運行測試套件和測試用例?

def tc = testRunner.testCase.testSuite.project.testSuites["FirstTestSuite"].testCases["FirstTestCase"] 

在測試情況下,我有這將創建一個Excel中的一些數據文件中的Web方法。現在,當我運行腳本時,我沒有調用web方法。我對此很陌生,所以我錯過了劇本中的任何內容?

也一旦我寫腳本有一種方法,我可以用crontab調用這個腳本?

謝謝。

回答

5

您還沒有編寫運行測試用例執行的代碼。嘗試使用此腳本:

//get test case from other project or from the same one 
project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName(project_name) 
testSuite = project.getTestSuiteByName(suite_name); 
testCase = testSuite.getTestCaseByName(testcase_name); 

//set properties if you need 
testRunner.testCase.setPropertyValue(property_name, property_value); 
testRunner.testCase.setPropertyValue(another_property_name, another_property_value); 

// run test case 
runner = testCase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false); 

此外還有一種方法可以使用crontab調用soap ui測試。

從命令行運行功能測試是使用包括在皁UI testrunner.bat/.SH腳本,這需要若干參數來控制哪些測試運行,輸出,例如直接的:

sh SmartBear/soapUI-4.5.1/bin/testrunner.sh -s"TestSuite 1" -r -a -fyour_folder/reports your_folder/your_project-soapui-project.xml 

其中
SmartBear/soapUI的-4.5.1 /斌/ testrunner.sh:路徑行書
-s 「的TestSuite 1」:測試套件名稱
-r:創建控制檯
-a總結報告:報告中輸出所有測試結果,不僅僅是錯誤
-fyour_folder /報告:路徑報表文件夾
您的文件夾/ your_project-的soapUI-project.xml中:路徑你的肥皂UI項目文件

點擊此處瞭解詳情:http://www.soapui.org/Test-Automation/functional-tests.html

而且在crontab中你只是需要啓動這個shell命令。

+0

感謝您的幫助。 – Valla

+0

對於您提到的groovy腳本。我可以使用crontab運行groovy腳本嗎?要清楚我是否寫上述腳本並將其保存爲.groovy,然後可以使用crontab運行它? – Valla

+0

不完全。我的意思是你可以使用crontab運行testrunner.sh。 Testrunner使用groovy腳本運行測試套件。 – ITemius

相關問題