Forum Discussion

DisTreSs's avatar
DisTreSs
Occasional Contributor
16 years ago

Schema compliance assertion export

Hi,

I would like to not just export the schema compliance assertion by exporting the testcase log, but would like to export it to an excel file for each test request in my test loop...
I'm not too script-savvy, so if someone would be able to tell me how to do this with a groovy script, that would be great.

To elaborate a bit, I can say we are already using a simple assertion to validate the content of a specific XML tag via a groovy script and the result of this script then gets datasinked to the excel-file. The problem now is that we have no idea on how to perform the shemacompliance assertion without using the built-in soapUI functionality or how to datasink a result from this built-in functionality. The easiest way therefore would be to just have a groovy-script which contains the schemacompliance and then, similar to the aforementioned scenario, simply datasink its result...

Thx-a-million in advance for your help! 

5 Replies

  • DisTreSs's avatar
    DisTreSs
    Occasional Contributor
    Anyone with any ideas?
    This would help me out bigtime
  • Hi,

    You should be able to use this script in a Script TestStep right after the Request in question. Change the name of the interface to the correct SOAP interface and modify the logging to instead write to an Excel file as in your other script. Good luck!

    def ctx = testRunner.testCase.testSuite.project.interfaces['interface_name'].wsdlContext
    def validator = new com.eviware.soapui.impl.wsdl.support.wsdl.WsdlValidator( ctx )
    def result = testRunner.results[testRunner.results.size()-1]
    def errors = validator.assertResponse( result, false )

    for( error in errors )
    log.info error



    Regards,
    Dain
    eviware.com
  • DisTreSs's avatar
    DisTreSs
    Occasional Contributor
    Hi Dain, thx very much for your reply!

    Unfortunately I'm getting an error when executing because of def result = testRunner.results[testRunner.results.size()-1]

    The error is: java.lang.ArrayIndexOutOfBoundsException: negative array index [-1] too large for array size 0.

    Changing the -1 value still puts it out of bounds...
    Only when I do not put a value does the script run but I don't believe I'm getting the desired outcome.

    The testrequest directly precedes the script in SoapUI as per your suggestion...
  • Hello,

    Hm..did you run just groovy step with that script of whole test case? You should run test case and preceding test request should get response for this to work.

    robert
  • DisTreSs's avatar
    DisTreSs
    Occasional Contributor
    Hi Robert, you're right, I was running the steps individually so I could monitor the output directly.
    Running the testcase in its entirity, the preceding teststep is found by the script so thx for that...

    I do however get some unwanted results from the script though.
    When I run a testcase where I know a schema compliance issue will be raised, the result from the script is for example: "[Lcom.eviware.soapui.model.testsuite.AssertionError;@c8010f", which is not quite the same as the more specific "org.apache.xmlbeans.XmlException: error: Unexpected element: CDATA" I get in the standard assertion.
    It might well be ofcourse that c8010f is an error code for this particular schema compliance deviation but is there some way this can be verified or is there another way to get the more specific message?

    Strangely enough though, even when a reply conforms to the schema and therefore passes the schema compliance without error raised,  I still get a similar message with the script ([Lcom.eviware.soapui.model.testsuite.AssertionError;@630657) as opposed to the built-in assertion that just lights up green...