{"id":19420820,"url":"https://github.com/kazurayam/katalon-studio-texts-diff","last_synced_at":"2025-06-17T01:37:05.077Z","repository":{"id":89769350,"uuid":"360714288","full_name":"kazurayam/katalon-studio-texts-diff","owner":"kazurayam","description":"a demo how to utilise the java-diff-utils library in Katalon Studio","archived":false,"fork":false,"pushed_at":"2024-02-12T05:19:13.000Z","size":8465,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-02-25T04:14:08.553Z","etag":null,"topics":["java-diff-utils","katalon-studio"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kazurayam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-23T00:09:43.000Z","updated_at":"2023-09-30T02:08:52.000Z","dependencies_parsed_at":"2024-02-12T06:41:34.001Z","dependency_job_id":null,"html_url":"https://github.com/kazurayam/katalon-studio-texts-diff","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/kazurayam/katalon-studio-texts-diff","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kazurayam%2Fkatalon-studio-texts-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kazurayam%2Fkatalon-studio-texts-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kazurayam%2Fkatalon-studio-texts-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kazurayam%2Fkatalon-studio-texts-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kazurayam","download_url":"https://codeload.github.com/kazurayam/katalon-studio-texts-diff/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kazurayam%2Fkatalon-studio-texts-diff/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260272727,"owners_count":22984381,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java-diff-utils","katalon-studio"],"created_at":"2024-11-10T13:25:33.748Z","updated_at":"2025-06-17T01:37:05.055Z","avatar_url":"https://github.com/kazurayam.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Utilizing java-diff-utils in Katalon Studio - Reborn\n\n- 1st release date: April, 2021\n- 2nd revision: Oct, 2023\n- 3rd revision: Feb, 2024\n- author kazurayam\n\nThis project presents a custom Keyword (a helper class in Groovy language) named `com.kazurayam.ks.TextsDiffer` to be used in [Katalon Studio](https://www.katalon.com/) projects.\n\nThe class was orignially developed using Katalon Studio v8.6.6 but is not dependent on the Katalon Studio's version. It should work on any newer versions of Katalon Studio as well.\n\n## How is this Git repository structured\n\nThis project reqpository 'katalon-studio-texts-diff' contains 3 sub directories: `lib-project`, `lib-project` and `docs`.\n\nThe `lib-project` contains a Katalon Studio project where I developed the source code of the Custom keyword for Katalon Studio. The `lib-project` has a `build.gradle` which build a jar file `katalon-studio-texts-diff-xxxxx.jar` that contains the custom keyword's binary. The jar file can be exported into any other Katalon Studio projects.\n\nThe `app-project` contains a Katalon Studio project where I imported the jar built in the `lib-project`. The Test Cases in the `app-project` demonstrates how to use the `katalon-studio-texts-diff` feature. To get started with the `katalon-studio-texts-diff`, you should look at the following code:\n\n- [app-project/Test Cases/ex01 diff 2 strings and write the report into file](https://github.com/kazurayam/katalon-studio-texts-diff/blob/develop/app-project/Scripts/ex01%20diff%202%20strings%20and%20write%20the%20report%20into%20file/Script1696166007171.groovy)\n\n## Problem to solve\n\nWeb testers often want to compare 2 text files. The files could be in various format: CSV, JSON, XML, etc. They sometimes just want to check if 2 texts are identical or not, and if not, they would want to see the differences. Katalon Studio does not offer any such feature. So I have created it.\n\n## Solution\n\nUtilize the [java-diff-utils](https://github.com/java-diff-utils/java-diff-utils/wiki) in Katalon Studio.\n\n\n## How to apply this to your own Katalon project\n\nIn the `Drivers` directory of your Katalon project, you NEED to install 3 external jar files.\n\n![Library Management](https://kazurayam.github.io/katalon-studio-texts-diff/images/LibraryManagement.png)\n\n1. [`java-diff-utils-4.12.jar`](https://mvnrepository.com/artifact/io.github.java-diff-utils/java-diff-utils/4.12)\n2. [`katalon-studio-texts-diff-x.x.x.jar`](https://github.com/kazurayam/katalon-studio-texts-diff/releases), the latest version\n3. [`java-diff-report-x.x.x.jar`](https://github.com/kazurayam/java-diff-report/releases), the latest version\n\nThe [`java-diff-utils-x.x.x`](https://github.com/java-diff-utils/java-diff-utils) is an open source library in Java for performing the comparison operations between texts. This enables us to generate diff information.\n\nUnfortunately the `java-diff-utils` library does not provide a code that generates human-readable reports out of box. To supplement this, kazurayam has developed a java library `java-diff-report`. This library provides a set of utility classes that generates human-readable reports easily.\n\nI developed the `katalon-studio-texts-diff-x.x.x` library which wraps the `java-diff-report` and the `java-diff-utils` library to utilize the texts diff feature in arbitrary Katalon Studio projects. With it, you will get a diff report in Markdown format with side-by-side view by just calling a custom keyword.\n\n## Creating and running your first test\n\nYou want to start Katalon Studio GUI and open your project.\n\nYou want to create a new Test Case `ex02` (... any name you can choose in fact), of which code looks as follows. You can just copy and paste this:\n\n```\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.nio.file.Paths\n\nimport com.kms.katalon.core.configuration.RunConfiguration\n\n/**\n * ex02 diff 2 strings and print the stats to console\n */\n\nString text1 = \"\"\"\u003cdoc\u003e\n\u003cbody\u003e\n\u003csection\u003e\n\u003cp\u003eHello, John!\u003c/p\u003e\n\u003c/section\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003c/body\u003e\n\u003c/doc\u003e\n\"\"\"\n\nString text2 = \"\"\"\u003cdoc\u003e\n\u003cbody\u003e\n\u003csection id=\"main\"\u003e\n\u003cp\u003eHello, Paul!\u003c/p\u003e\n\u003cp\u003eHave a break!\u003c/p\u003e\n\u003c/section\u003e\n\u003c/body\u003e\n\u003c/doc\u003e\n\"\"\"\n\n// output\nPath outDir = Paths.get(RunConfiguration.getProjectDir()).resolve(\"build/tmp/testOutput\")\nFiles.createDirectories(outDir)\nPath reportFile = outDir.resolve(\"ex02-output.md\")\n\n// pass 2 arguments of String to receive a report in Markdown format\nString stats = CustomKeywords.'com.kazurayam.ks.TextsDiffer.diffStrings'(text1, text2, reportFile.toString())\nprintln stats\n\nString report = reportFile.text;\nassert report.contains(\"**DIFFERENT**\")\nassert report.contains(\"inserted rows\")\nassert report.contains(\"deleted rows\")\nassert report.contains(\"changed rows\")\nassert report.contains(\"equal rows\")\n\nassert report.contains(\"| 1 |\")\nassert report.contains(\"\u0026lt;doc\u0026gt;\")\n\n```\n\nNow you can run this Test Case as usual in Katalon Studio by clicking the green button ![run](./docs/images/run_katalon_test.png).\n\nOnce done, the script will write a file `build/tmp/testOutput/ex02-output.md`. The text will be formatted in Markdown. The file will like this:\n\n```\n### Stats\n\n**DIFFERENT** at 2024-02-07 09:01:07\n\n- inserted rows : 1\n- deleted rows  : 1\n- changed rows  : 2\n- equal rows:   : 5\n\n### Detail\n\n|row#|S|original|revised|\n|----|-|--------|-------|\n| 1 |   | \u0026lt;doc\u0026gt; | \u0026lt;doc\u0026gt; |\n| 2 |   | \u0026lt;body\u0026gt; | \u0026lt;body\u0026gt; |\n| 3 | C | \u003cspan style=\"color:red; font-weight:bold; background-color:#ffeef0\"\u003e\u0026lt;section\u0026gt;\u003c/span\u003e | \u003cspan style=\"color:green; font-weight:bold; background-color:#e6ffec\"\u003e\u0026lt;section id=\"main\"\u0026gt;\u003c/span\u003e |\n| 4 | C | \u0026lt;p\u0026gt;Hello, \u003cspan style=\"color:red; font-weight:bold; background-color:#ffeef0\"\u003eJohn!\u0026lt;\u003c/span\u003e/p\u0026gt; | \u0026lt;p\u0026gt;Hello, \u003cspan style=\"color:green; font-weight:bold; background-color:#e6ffec\"\u003ePaul!\u0026lt;\u003c/span\u003e/p\u0026gt; |\n| 5 | I |  | \u003cspan style=\"color:green; font-weight:bold; background-color:#e6ffec\"\u003e\u0026lt;p\u0026gt;Have a break!\u0026lt;/p\u0026gt;\u003c/span\u003e |\n| 6 |   | \u0026lt;/section\u0026gt; | \u0026lt;/section\u0026gt; |\n| 7 | D | \u003cspan style=\"color:red; font-weight:bold; background-color:#ffeef0\"\u003e\u0026lt;p\u0026gt;\u0026lt;/p\u0026gt;\u003c/span\u003e |  |\n| 8 |   | \u0026lt;/body\u0026gt; | \u0026lt;/body\u0026gt; |\n| 9 |   | \u0026lt;/doc\u0026gt; | \u0026lt;/doc\u0026gt; |\n\n```\n\nA Markdown text in raw format is hard to read in a plain text editor. You would definitely require some viewer application tailored for Markdown. For example, I personally use [Visual Studio Code, Markdown preview](https://code.visualstudio.com/Docs/languages/markdown#_markdown-preview). You can preview the report in VSCode as follows.\n\n![VSCode with Markdown Viewer](https://kazurayam.github.io/katalon-studio-texts-diff/images/ex02.png)\n\nThis looks nice, doesn't it?\n\n## Compact report\n\nYour input texts sometimes could be very long. Let me assume, for example, that I want to compare the following 2 texts.\n\n1. [bootstrap-icons.css 1.5.0](https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css)\n2. [bootstrap-icons.css 1.7.2](https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css)\n\nBoth of them are very long: over 1500 lines. And these texts are slightly different, as the following stats shows:\n\n- inserted rows : 166\n- deleted rows  : 0\n- changed rows  : 2\n- equal rows:   : 1388\n\nObviously I am only interested in the difference (inserted, deleted, changed); I am not interested in the equal parts. In this case, approximately 90% of lines are not interesting for me. I do not like the diff report to contain the boring equal lines.\n\nSo, the `java-diff-report` library supports 2 format of diff report: \"compact\" and \"full\". You can chose either by specifying a parameter. \"compact\" is the default. The compact report will trim most of the equal lines. The diff report of the above inputs will contain have only 200 lines, not 1500 lines.The report will look something like this:\n\n![large inputs](https://kazurayam.github.io/katalon-studio-texts-diff/images/diff_large_inputs.png)\n\nPlease note that there is a gap between the line#24 and line#1391 where hundreds of \"equal\" lines are trimmed off. Therefore the report file is small and easy to look through quickly.\n\n\n## More types of input text\n\nThe sample Test Case `ex02` uses `com.kazurayam.ks.TextsDiffer.diffStrings()` method that takes 2 Strings as input. The `com.kazurayam.ks.TextsDiffer` class implements more variations of method signature that can take other types: `java.io.File`, `java.nio.Path` and `java.net.URL`.\n\nSee the [`Examples`](https://kazurayam.github.io/katalon-studio-texts-diff/) document for more use cases.\n\n## API\n\nYou can have a look at the API documentation of `TextsDiffer` class at\n\n- [API doc](https://kazurayam.github.io/katalon-studio-texts-diff/api/index.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkazurayam%2Fkatalon-studio-texts-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkazurayam%2Fkatalon-studio-texts-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkazurayam%2Fkatalon-studio-texts-diff/lists"}