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

Val*_*lla 2 groovy soapui crontab

我有名称的测试套件,FirstTestSuite然后创建一个名为testCase FirstTestCase.我在soap UI中编写了一个groovy脚本,如下所示:

def tc = testRunner.testCase.testSuite.project.testSuites["FirstTestSuite"].testCases["FirstTestCase"]
Run Code Online (Sandbox Code Playgroud)

在测试用例中,我有一个web方法,它创建一个带有一些数据的excel文件.现在,当我运行脚本时,我没有调用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);
Run Code Online (Sandbox Code Playgroud)

还有一种使用crontab调用soap ui测试的方法.

使用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
Run Code Online (Sandbox Code Playgroud)

其中
SmartBear/soapUI-4.5.1/bin/testrunner.sh:运行脚本的路径
-s"TestSuite 1":测试套件名称
-r:在控制台中创建摘要报告
-a:导出报告中的所有测试结果,不仅errors
-fyour_folder/reports:报告文件夹的路径your_folder/
your_project-soapui-project.xml:soap ui项目文件的路径

更多信息请访问:http://www.soapui.org/Test-Automation/functional-tests.html

在crontab中你只需要启动这个shell命令.