Comparing 2 texts in Katalon Studio

I have published a GitHub project:


Problem to solve

Web testers often want to compare 2 text files. The files could be in various format: CSV, JSON, XML, etc.

As minimum requirement, they want to know if 2 texts are completely identical or not.

Additionally they want to see the differences, if any, in human-readable format, such as Markdown.

Testers usually do not require Patching features which many “diff utilities” provides.

I want to perform texts-diff and reporting in Katalon Studio.

Solution

Utilize java-diff-utils in Katalon Studio.

How to run the demo

  • Download the zip of this project from the Releases page, unzip it, open it with your Katalon Studio.
  • In the <projectDir>/Drivers directory, you will find java-diff-utils-4.9.jar installed.
  • open Test Cases/TC1 and run it.
  • the script will compare 2 xml files
  • it will create a diff report in Markdown format, save it into a file <projectDir>/out.md

How the report looks like

The <projectDir>/out.md will be formated in Markdown like this:

- original: `/Users/username/projectdir/Include/fixtures/doc1.xml`
- revised : `/Users/username/projectdir/Include/fixtures/doc2.xml`

**DIFFERENT**

- inserted rows: 0
- deleted rows : 0
- changed rows : 3
- equal rows:  : 5

|line#|original|revised|
|-----|--------|-------|
|1|&lt;doc&gt;|&lt;doc&gt;|
|2|&lt;body&gt;|&lt;body&gt;|
|3|*&lt;section&gt;*|**&lt;section id="main"&gt;**|
|4|&lt;p&gt;Hello, *John!&lt;*/p&gt;|&lt;p&gt;Hello, **Paul!&lt;**/p&gt;|
|5||**&lt;p&gt;Have a break!&lt;/p&gt;**|
|6|&lt;/section&gt;|&lt;/section&gt;|
|7|&lt;/body&gt;|&lt;/body&gt;|
|8|&lt;/doc&gt;|&lt;/doc&gt;|

I copy & past it here:


  • original: /Users/username/projectdir/Include/fixtures/doc1.xml
  • revised : /Users/username/projectdir/Include/fixtures/doc2.xml

DIFFERENT

  • inserted rows: 0
  • deleted rows : 0
  • changed rows : 3
  • equal rows: : 5
line# original revised
1 <doc> <doc>
2 <body> <body>
3 <section> <section id=“main”>
4 <p>Hello, John!</p> <p>Hello, Paul!</p>
5 <p>Have a break!</p>
6 </section> </section>
7 </body> </body>
8 </doc> </doc>

I think it is readable enough. Of course you can change the Test Case code so that it outputs in any format you like.

Where to get external dependencies

1 Like