mardi 25 octobre 2016

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

log.info "_____Start of Log_____"

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

StepList.each
    {
        if(it.metaClass.hasProperty(it,'assertionStatus')){
            Total = Total + 1
            def assertions = it.getAssertionList()
            assertions.each
            { assertion ->
                if(it.assertionStatus == AssertionStatus.FAILED)
                {
                    assertion.getErrors().each
                    { error ->
                        log.error "${it.name}: [FAILED] ${error.getMessage()}"
                    }
                    Failed = Failed + 1
                }
            }               
        }   
    }
log.info " Script Run: " + Total
log.info " Scripts Failed: " + Failed
log.info "_____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.

Aucun commentaire:

Enregistrer un commentaire