Forum Discussion

Cleo-Juniper's avatar
Cleo-Juniper
New Contributor
11 months ago

How do I set the status of a Script Assertion?

After looking at this documentation, GroovyScriptAssertion (SoapUI 3.0.0 API) (smartbear.com), I've tried the following

 

def currentStep = context.getCurrentStep();

def assertion = currentStep.getAssertionByName('Script Assertion');

assertion.setStatus(com.eviware.soapui.model.testsuite.Assertable.AssertionStatus.FAILED);

 

but I get the error


setStatus() exception: groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.GroovyScriptAssertion.setStatus() is applicable for argument types: (com.eviware.soapui.model.testsuite.Assertable$AssertionStatus) values: [FAILED]

 

If I output

 

assertion.getClass()

 

It tells me that assertion's class is 

 

com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.GroovyScriptAssertion@71d72a30

 

What am I doing wrong?  I'm using 5.7.1

 

Edit:

If it's not possible to set the status of a test assertion or test step, is it possible to set the status of a testCase?

  • Hello Cleo-Juniper 

     

    Your question seems to be getting pretty deep for handling the response of a Script Assertion.  I don't know your intent on setting this, but I will assume you are new to SoapUI and are trying too hard to make work for yourself.  🙂

     

    The result of the outcome of one line of code will set the status of a script assertion...  You do not have to code the plumbing to get a status (unless you want to). 

     

    Use the 'assert' statement:

    assert evalEndDate > nowDate, "Expected EndDate to be greater than now";

     

    If the result of executing the assert statement is true, then the result of the Script Assertion will be "PASSED" or similar.

    If the result of executing the assert statement is false, then the result of the Script Assertion will be "FAILED" or similar.

     

    Sorry if I deviated from your intent (which i had to make an assumption), but this is an answer to your title question.

     

    Regards,

    Todd