Forum Discussion

jcsalter's avatar
jcsalter
New Contributor
11 months ago

ReadyAPI Smart Assertion

Is it possible to "export" a Smart Assertion to a .txt file?

3 Replies

    • jcsalter's avatar
      jcsalter
      New Contributor

      The use case is that the Smart Assertion is "graphic" and an exported version is "text".

        I can have "50" entries in the Smart Assertion but only have one enabled.

        I would like to export out the assertion to a text format and then replace the Smart Assertion with it.

        Can I look at the structure of the Smart Assertion and manually build the 'text' version?

        Absolutely.

          But it's error prone and I would much rather push a button to do the work for me.

       

  • shyne's avatar
    shyne
    Occasional Contributor

    Not as far as I know in the ReadyAPI software 😞. Ideally you'd want to import (dynamically) too! Its a massive flaw of Smart Assert imho. We've created our own Groovy script that uses a JSON file that acts as a map, to assert the properties of the test data and the returned data.

     

    For a more manual method, in a composite project you could look at the source files 🤤 e.g.

    <?xml version="1.0" encoding="UTF-8"?>
    <con:testCase xmlns:con="http://eviware.com/soapui/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="cba17ad8-eaa2-4780-b626-32a9924b564d" discardOkResults="false" failOnError="false" failTestCaseOnErrors="true" keepSession="false" name="Test Case 1" searchProperties="true" timeout="0">
      <con:settings id="b770fa28-5ff4-4b15-b725-af70cc98a55c">
        <con:setting id="cba17ad8-eaa2-4780-b626-32a9924b564dfileName">Test-Case-1</con:setting>
      </con:settings>
      <con:testStep type="groovy" name="Groovy Script" id="d4dcd68e-a392-49de-9d6c-a6576304e488">
        <con:settings/>
        <con:config>
          <script>"""
    {
      "abc":"def",
      "ghi":"jkl"
    }
    """</script>
        </con:config>
      </con:testStep>
      <con:testStep type="assertionteststep" name="Assertion" id="5d473562-aba5-4574-819f-e9ddf2c622d8">
        <con:settings/>
        <con:config xsi:type="con:AssertionTestStep">
          <con:entry>
            <con:id>87c63781-b2f0-45cf-b9e0-c42a9f974732</con:id>
            <con:isGroup>false</con:isGroup>
            <con:sourceId>d4dcd68e-a392-49de-9d6c-a6576304e488</con:sourceId>
            <con:propertyName>result</con:propertyName>
            <con:assertion type="DataAndMetadataAssertion" name="Smart Assertion" id="8e970b5a-5798-4eec-a116-9927810845df">
              <con:configuration xsi:type="con:DataAndMetadataAssertion">
                <con:mode>Received Data</con:mode>
                <con:elements>
                  <con:path>$['abc']</con:path>
                  <con:element>abc</con:element>
                  <con:operatorId>1</con:operatorId>
                  <con:enabled>true</con:enabled>
                  <con:expectedValue>def</con:expectedValue>
                  <con:caseSensitive>true</con:caseSensitive>
                  <con:numberType>false</con:numberType>
                  <con:expectedDataType>1</con:expectedDataType>
                </con:elements>
                <con:elements>
                  <con:path>$['ghi']</con:path>
                  <con:element>ghi</con:element>
                  <con:operatorId>1</con:operatorId>
                  <con:enabled>true</con:enabled>
                  <con:expectedValue>jkl</con:expectedValue>
                  <con:caseSensitive>true</con:caseSensitive>
                  <con:numberType>false</con:numberType>
                  <con:expectedDataType>1</con:expectedDataType>
                </con:elements>
                <con:originalMessage>{
      "abc":"def",
      "ghi":"jkl"
    }</con:originalMessage>
              </con:configuration>
            </con:assertion>
          </con:entry>
        </con:config>
      </con:testStep>
      <con:properties/>
      <con:reportParameters/>
    </con:testCase>