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

时间:2013-07-22 15:27:43

标签: groovy crontab soapui

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

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

在测试用例中,我有一个web方法,用于创建包含一些数据的excel文件。现在,当我运行脚本时,我没有调用web方法。我是新手,所以我错过了剧本中的任何内容吗?

此外,一旦我编写脚本,我可以使用crontab调用此脚本吗?

感谢。

1 个答案:

答案 0 :(得分: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测试的方法。

使用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_folder / reports:报告文件夹的路径
your_folder / your_project-soapui-project.xml:soap ui项目文件的路径

此处提供更多信息:http://www.soapui.org/Test-Automation/functional-tests.html

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

相关问题