2
votes

I have test suite with name FirstTestSuite and then created a testCase named FirstTestCase. I have written a groovy script in the soap UI like this:

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

In the test case I have a web method which creates a excel file with some data. Now when I run the script the web method I not called. I am new to this so did I miss anything in the script?

Also once I write the script is there a way by which I can call this script using crontab?

Thanks.

1

1 Answers

5
votes

You haven't wrote the code which runs test case execution. Try to use this script:

//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);

Also there is a method to call soap ui tests using crontab.

Running functional tests from the command-line is straightforward using the included in soap ui testrunner.bat/.sh script, which takes a number of arguments to control which tests to run, output, for example:

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

where
SmartBear/soapUI-4.5.1/bin/testrunner.sh : path to running script
-s"TestSuite 1" : test suite name
-r : create summary report in console
-a : exporting of all test results in report, not only errors
-fyour_folder/reports : path to your reports folder
your_folder/your_project-soapui-project.xml : path to your soap ui project file

More information here: http://www.soapui.org/Test-Automation/functional-tests.html

And in crontab you just need to start this shell command.