Forum Discussion
Before running the below code download xmlunit jar file and Copy XMLUnit jar file under SOAPUI_HOME/bin/ext, then restart soapui.
The below code is written inside ( TestSuite-->TestCase-->Groovy Script -->)
Look for references here
import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.List; import org.custommonkey.xmlunit.DetailedDiff; import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.Difference; import org.xml.sax.SAXException; def String path01="C:\\SoapOutPut\\Base\\TEST_ReqV03_GetV02.xml"; def String path02="C:\\SoapOutPut\\Base\\TEST_ReqV04_GetV03.xml"; // Calling function to validate the outcome ComparisonTest (path01,path02) def ComparisonTest (filepathOrginal,filepathnew) { FileReader fr1 = null; FileReader fr2 = null; try { fr1 = new FileReader(filepathOrginal); fr2 = new FileReader(filepathnew); } catch (FileNotFoundException e) { e.printStackTrace(); } try { Diff diff = new Diff(fr1, fr2); log.info ("Similar record is --> " + diff.similar()); log.info ("Identical record is --> " + diff.identical()); DetailedDiff detDiff = new DetailedDiff(diff); List differences = detDiff.getAllDifferences(); for (Object object : differences) { Difference difference = (Difference)object; log.info ("***********************"); log.info(difference); log.info("***********************"); } } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
hey this code is not working.
- ShasiSingh6 years agoOccasional Contributor
Hi, This is a working Code, if you are using XML, But your question Title suggest ( Compare text files ) , and your shared sample talking about XML and your comments are talking about jason.
What you are looking for ? and where you have an error. could you please share the same.
- radhika16 years agoContributoryes this code is working but unfortunately i need only the tag names and I do not want to print any value mismatches for it. Can we have that code as well please.
- radhika16 years agoContributor
Hello,
This code is working but i do not want the value mismatches in it.I need only the node name mismatches.
- radhika16 years agoContributor
Hello,
This code is working but i do not want the value mismatches in it.I need only the node name mismatches.
- radhika16 years agoContributorCan some one help me please.
Related Content
Recent Discussions
- 22 hours agoKLWallace
- 7 days agoruchisingh