Ross Ross - 2 months ago 12
Groovy Question

SoapUI: Have a separate Test Suite that runs a GroovyScript TestStep that checks all other Test Cases In other Test Suites?

I have a Groovy Script that reads the Assertion Validation and Error message of the test steps that have been run in the current test case.

I currently have 4 Test Suites, with 8 Test Cases, all with around 400 Test Steps.

Is it possible to have a separate Test Suite with one Test Case and one Test Step that hold the groovy script?

The sole purpose of this Test Suite would be to run the groovy test step that reads all other Test Suite and the test cases, test steps and logs the failed test steps.

import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus

def TestSuite = testRunner.getTestCase()
def StepList = TestSuite.getTestStepList()

Failed = 0
Total = 0 "_____Start of Log_____"

// psuedo code
// SuiteList.each
// CaseList.each

Total = Total + 1
def assertions = it.getAssertionList()
{ assertion ->
if(it.assertionStatus == AssertionStatus.FAILED)
{ error ->
log.error "${}: [FAILED] ${error.getMessage()}"
Failed = Failed + 1
} " Script Run: " + Total " Scripts Failed: " + Failed "_____End of Log_____"

At the moment my output is:

Tue Oct 25 12:55:20 BST 2016:ERROR:TestStep_0299: [FAILED] Expected Result: 49.401 or 52.002 or 54.602 Actual Result: 41.60164055168. Expression: node.toString().matches((49.401|52.002|54.602)\d*)
Tue Oct 25 12:55:20 BST 2016:ERROR:TestStep_0300: [FAILED] Expected Result: 61.752 or 65.002 or 68.252 Actual Result: 52.0020506896. Expression: node.toString().matches((61.752|65.002|68.252)\d*)
Tue Oct 25 12:55:20 BST 2016:INFO: Script Run: 300
Tue Oct 25 12:55:20 BST 2016:INFO: Scripts Failed: 205
Tue Oct 25 12:55:20 BST 2016:INFO:_____End of Log_____

Is it possible to run this for all test suites and test case. so i have one big log of all test steps.

Is this possible within SoapUI.

Rao Rao

Here is the Groovy Script that loops thru all the suites except the current suite as it is not needed in your case.
Please follow the in-line comments.

 * This script gets all the suites and 
 * removes current suite name from total list
 * and loopes thru the test cases of each suite

//Get the project object
def project = context.testCase.testSuite.project

//Get the current suite name
def currentSuite =

//Get the suites to process (except the current suite)
def suites = project.testSuiteList.findAll {it}*.name - currentSuite

//Loop thru the suites, followed by cases in each suite
suites.each { suite ->
    def tSuite = project.getTestSuiteByName(suite)
    tSuite.testCaseList.each { kase ->
        kase.testStepList.each {
            //Have your code here