Forum Discussion

yashm7's avatar
yashm7
New Contributor
10 years ago

Automated methods to compare responses from 2 endpoints

I am performing data driven testing using groovy scripts by retrieving xml files stored in local drive and triggering requests to 2 end points. The responses from both the end points are collected and saved in local drive in xml formats.
Please help in writing a groovy script for file comparison - the existence of first node from xml1 has to be validated in Xml2. Likewise it has to pick all the nodes from xml1 and validate its existence in xml2. Since i am performing this for bulk data, want to get this done through automated methods.

4 Replies

  • srirajms's avatar
    srirajms
    New Contributor
    Hi,

    Can you share the project for what ever you have achieved till now ? even i am in search of a solution for this requirement.

    Thanks
    Sri - srirajms@gmail.com
    • yashm7's avatar
      yashm7
      New Contributor

      Hi,

       

      You can use below script to fetch files from a folder.

       

      import java.io.File;
      import java.util.Date;
      import jxl.*;
      def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
      import groovy.sql.Sql
      def fileList = []
      new File("path where u hv stored the files").eachFile{ f ->
      if (f.isFile()&& f.name.contains('.xml'))
      {
       def filename = f.name[0..-1]
       fileList.add(filename)
       log.info filename
      }
      }
      if (fileList.size() <1)
      {
      testRunner.fail("No request files found")
      }
      context.put('fileList',fileList)

      • nmrao's avatar
        nmrao
        Champion Level 3
        This is not the requirement of the original author of this topic.