running a test suite and test case using groovy?

11,370

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.

Share:
11,370
Valla
Author by

Valla

Updated on June 04, 2022

Comments

  • Valla
    Valla almost 2 years

    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.

  • Valla
    Valla almost 11 years
    Thanks for your help.
  • Valla
    Valla almost 11 years
    For the groovy script that you have mentioned. Is it possible that I can run the groovy script using crontab ? To be clear if I write the above mentioned script and save it as .groovy and then can I run it using crontab ?
  • ITemius
    ITemius almost 11 years
    Not quite. I meant that you can run testrunner.sh using crontab. And testrunner runs your test suite with groovy script.
  • Valla
    Valla almost 11 years
    the problem is I have centOS and the soapUI is installed on my windows machine.So the testrunner.sh file would not be available in the centOS and i cannot execute the command. So is it that the only solution would installing jre and soapUI on my linux machine and then running the script?
  • ITemius
    ITemius almost 11 years
    If you want to run soap ui tests, naturally you need to install soap ui ;) I use exactly that solution to run automatic tests for REST apis