Forum Discussion

yakima's avatar
yakima
Occasional Contributor
9 years ago

How to transfer a message from an Assertion to a DataSink

I am a Ready! API (1.4.1) SoapUI NG user and I need help regarding the transfer of a message from an Assertion to a DataSink.

 

Here is my scenario.

 

I run a web service thay returns all the products a client may have. There may be more than one element return and his 'Health' product may be returned in anyone. I cannot tell in which element it will be, if it even exists.

 

Health 1.jpg

 

In this case it is in the second element.

Health 2.jpg

 

Ultimately, I have an assertion to check whether the word 'Health' is found anywhere with the returned XML. Here I am doing it with an Assertion Step. I am not failing the Assertion as I only want to know whether a client has Health or not. I want to continue with the DataLoop but I want a report where I write the Message from the Assertion to a file next to the Client Number.

 

Health 3.jpg

 

So Property Transfer offers me the chance to use the Assertion as Source, but I cannot choose a Property from the Assertion. The Property dropdown is disabled.

Health 4.jpg

 

So ultimately, I just want a result to be returned. Whether it is the Test Step passed or failed, or the Assertion status, or anything that can tell me whether I found the value or not.

 

Any assistance will be greatly appreciated.

 

Health 5.jpg

2 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Yakima,

     

    As you don’t know the exact response those value you want to write to a file, I would suggest that you create your own script that will search for the needed value in the entire request and post the results to a file. You can find a sample of how to work with Excel via Groovy here or here.

    • goliontus's avatar
      goliontus
      Occasional Contributor

      Thank you very much.

       

      Personally, I would like to keep my scripts as simple as possible and refrain from Groovy Scripts where there is not other way around. It makes it easier to maintain by not so technical resources.

       

      Since this Groovy script was a solution, I would expect the functionality to be built in to easy transfer the message from the assertion to a parameter to be written to the Data Sink.

       

      This script worked for me. I'm storing the result in a global variable and reading it from the Data Sink.

       

      def testStep = testRunner.testCase.getTestStepByName('TestStepName')
      // print assertion names an its status
      testStep.getAssertionList().each{
          com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils.globalProperties['testResult'].value = "$it.label - $it.status"   
      }