DZone's Guide to

Resolve Git Conflicts Using Katalon Studio

See how the Katalon Studio automated testing framework can be used to prevent conflicts when using Git for source control.

· DevOps Zone
Free Resource

How to Set Up Continuous Integration Pipelines with Drone on Ubuntu 16.04. Get the DigitalOcean detailed tutorial.

Why Do We Have Git Conflicts?

In a source control system like Git, conflicts may occur when two or more people make changes to the same file concurrently. The conflicts may appear at a member’s local repository or Git remote repository. In order to avoid conflicts, the team must collaborate following several Git practices. For example, before pushing new source code to the Git remote repository, one must remember to fetch the latest version from Git remote repository, resolve any conflicts and merge the code with the local version.

The chart below demonstrates how conflicts may occur when Tom and Emma are working on the same project. The conflicts occur when Tom and Emma try to push new code to the Git remote repository without updating the changes from each other.

Git conflicts Katalon Studio


Resolve Git Conflicts Using Katalon Studio

Let’s consider the following situation: Tom and Emma are working on the same test case in a test project. Emma added a new comment (“EMMA ADDED THIS COMMENT”), then committed and pushed the change to the Git remote repository.

Resolve Git Conflict Katalon Studio

At almost the same time, Tom also added a new comment (“TOM ADDED THIS COMMENT”), then committed and tried to push to the Git remote repository.

Resolve Git Conflict Katalon Studio

Unfortunately, since Emma had pushed the code before Tom, the version of the code in Git was different from the version of the code in Tom’s local repository and therefore, Git rejected Tom’s “push” action.

What should Tom do to push his change to the Git remote control?

First, Tom has to “pull” the code from the Git remote repository to his local machine.

Obviously, Tom will see a message about the conflict:

Resolve Git conflict

In the “Script” mode of the test case “TC2_Verify Successful Appointment” in Tom’s Katalon Studio project, there are errors with indicators such as “<<<<<<<” (convention from Git). Let’s look at the script more carefully:

Resolve Git conflict

Recall that the comments were added by Tom and Emma, and the “conflict” is now on Tom’s Katalon Studio project. Everything within “<<<<<<< HEAD” and “=======” is the change from Tom. And, everything within “=======” and “>>>>>>> branch ‘master’…” comes from Emma, which is currently in the Git remote repository.

Now Tom has to decide which change is correct, or both are correct or wrong. Tom has to replace these lines of code by the correct one, e.g. “THIS IS THE CORRECT COMMENT”:

Resolve Git conflict

After resolving the conflict, Tom is now able to commit and push the change to the Git remote repository.

Notes

In order to minimize the conflict in a team having more than one members, you should define a process from the very beginning so that all team members are on the same page when using Git. Here are some suggestions for good practices:

Best Practices in Katalon Studio Integration With Git

Git is a very powerful system for source version control, so if you have more than one member on your Katalon Studio project, you may consider using Git as a remote repository for your testing project. The content below provides several typical workflows for working with Git using Katalon Studio. Each workflow is presented via a diagram with each activity being taken from either Katalon Studio, Git, or Local Repository.

The activities involve performing one or more commands on Katalon Studio and Git:

1. Katalon Studio:

2. Git:

Below are some good practices in using Katalon Studio integration with Git.

Starting a Katalon Studio Project With Git

Below is a recommended workflow for starting a new Katalon Studio project and integrating with Git. The main activities in this workflow include Katalon Studio Registration, enabling Git integration, creating a Git repository, and cloning the project to Katalon Studio.

Starting-Katalon-with-Git

Add an Existing Katalon Studio Project Into a New Git Repository

In case you have an existing Katalon Studio project and you want to add it to a Git repository and share it with team members, you can apply the following workflow. This workflow involves Commit and Push changes to Git.

add-Katalon-project-into-new-Git

Add an Existing Katalon Studio Project to an Existing Git Repository

Very often, we have a Git repository from the development team for storing production code. The QA/tester team is required to save automation test scripts into this repository under a "test" folder.

You can apply the following steps to start a new Katalon Studio project and integrate it with the existing Git repository from the development team:

Start Katalon project in existing Git

The situation is a bit more complicated if your automation team already works on a Katalon project for a while and tries to add it to an existing Git repository of the development team. In this case, you can apply the following workflow. In this workflow, you have to move the existing Katalon automation project into the test folder of the development’s local repository. You then open the Katalon project from Katalon Studio.

add Katalon project into existing Git

For further instructions and help, please refer to the Katalon Studio Tutorials and Katalon Forum.

We did the research and have the tutorials on how to install the top CI/CD tools. See how Jenkins, Gitlab CI, Buildbot, Drone and Concourse compare.

Opinions expressed by DZone contributors are their own.