Forum Discussion

mrdwprice's avatar
mrdwprice
Contributor
5 years ago
Solved

Disable Assertions using Setup script

I'm trying to disable a specific test step assertion using SetUp script   def ts = runner.project.getTestSuiteByName("TestSuite") ts.getTestCaseByName("TestCase").getTestStepByName("TestStep1").??...
  • Radford's avatar
    5 years ago

    What is the type of test step type are you trying to disable the schema compliance assertion on? because if it is a WSDL test step the class WsdlTestRequestStep has the method getAssertionByName.

     

    The following is a bit of code that is run from test case startup script that loops through all of the test steps and all of the assertions, and disabling all of the schema compliance assertions, hopefully this will give you some pointers.

     

    testCase.getTestSteps().each{testStepName, testStep  ->
        // Only check the test step if it implements the assertable interface
        if (testStep in com.eviware.soapui.model.testsuite.Assertable){
            testStep.getAssertionList().each{ testAssertion ->
    
                log.info('Test step "' + testStepName + '" Checking assertion "' + testAssertion.getName() +'"')
                
                if(testAssertion in com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.SchemaComplianceAssertion){
                    log.info('"' + testAssertion.getName() + '" is a schema compliance assertion, disable it.')
                    testAssertion.setDisabled(true)
                }
                
            }
        }
    }