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

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

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

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

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

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

Highlighted
Community Manager

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

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get a full Raw JMS request

Participate!

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors