使用groovy运行测试套件和测试用例?

使用groovy运行测试套件和测试用例?,groovy,crontab,soapui,Groovy,Crontab,Soapui,我有一个名为FirstTestSuite的测试套件,然后创建了一个名为FirstTestCase的测试用例。我在soap UI中编写了如下groovy脚本: def tc = testRunner.testCase.testSuite.project.testSuites["FirstTestSuite"].testCases["FirstTestCase"] 在测试用例中,我有一个web方法,它创建一个包含一些数据的excel文件。现在,当我运行脚本时,我没有调用web方法。我是新手,所以我

我有一个名为
FirstTestSuite
的测试套件,然后创建了一个名为
FirstTestCase
的测试用例。我在soap UI中编写了如下groovy脚本:

def tc = testRunner.testCase.testSuite.project.testSuites["FirstTestSuite"].testCases["FirstTestCase"]
在测试用例中,我有一个web方法,它创建一个包含一些数据的excel文件。现在,当我运行脚本时,我没有调用web方法。我是新手,所以我错过了剧本中的任何东西吗

还有,一旦我编写了脚本,有没有一种方法可以使用crontab调用这个脚本


谢谢。

您还没有编写运行测试用例执行的代码。尝试使用以下脚本:

//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调用soapui测试的方法

使用包含在soap 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/bin/testrunner.sh:运行脚本的路径
-s“TestSuite 1”:测试套件名称
-r:在控制台中创建摘要报告
-a:导出报告中的所有测试结果,而不仅仅是错误
-fyour_文件夹/报告:报告文件夹的路径
您的\u文件夹/your\u project-soapui-project.xml:soap ui项目文件的路径

更多信息请点击此处:


在crontab中,您只需要启动这个shell命令。

感谢您的帮助。感谢您提到的groovy脚本。我是否可以使用crontab运行groovy脚本?为了弄清楚,如果我编写上述脚本并将其另存为.groovy,然后我可以使用crontab运行它吗?不太清楚。我的意思是您可以使用crontab运行testrunner.sh。testrunner使用groovy脚本运行您的测试套件。问题是我有centOS,并且soapUI安装在我的windows计算机上。因此testrunner.sh文件在centOS中不可用,我无法执行该命令。那么,唯一的解决方案是在我的linux机器上安装jre和soapUI,然后运行脚本吗?如果您想运行soapUI测试,自然需要安装soapUI;)我正是使用这个解决方案来运行RESTAPI的自动测试