cancel
Showing results for 
Search instead for 
Did you mean: 

Disable Assertions using Setup script

SOLVED
Highlighted
Occasional Contributor

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

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super Contributor

Re: Disable Assertions using Setup script

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

 

View solution in original post

4 REPLIES 4
Highlighted
Super Contributor

Re: Disable Assertions using Setup script

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

 

View solution in original post

Highlighted
Community Hero

Re: Disable Assertions using Setup script

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?



Regards,
Rao.
Highlighted
Occasional Contributor

Re: Disable Assertions using Setup script

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

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

Community Manager

Re: Disable Assertions using Setup script

Thank you for looking into this, Community!

Hi @mrdwprice , were you able to find a solution? Please share the progress with us Smiley Happy


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors