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").????

getAssertionbyName does not seem to be available in this context though...

 

How for example can I disable the "Schema Compliance" assertion for "TestStep1"?

 

Thanks

  • 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)
                }
                
            }
        }
    }

     

4 Replies

  • Radford's avatar
    Radford
    Super Contributor

    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)
                }
                
            }
        }
    }

     

  • nmrao's avatar
    nmrao
    Champion Level 3
    What is the use case?
    If it is single time, isn't it simple to disable by hand? If it is for every time and they why is it there at all if not needed?

    • mrdwprice's avatar
      mrdwprice
      Contributor

      Use case: I have tests that execute across multiple environments using testrunner.bat

      Depending on the Active environment, certain Assetions should be disabled.

      • sonya_m's avatar
        sonya_m
        SmartBear Alumni (Retired)

        Thank you for looking into this, Community!

        Hi mrdwprice , were you able to find a solution? Please share the progress with us :smileyhappy: