Same as in version control for code, but slightly different, Applitools supports a branching mechanism.
The main difference is that branches in Applitools contain visual baselines instead of code.
The branching mechanism in Applitools allows the user to create, maintain and merge branches easily.
This article covers the following topics:
- Creating a new branch via the Test Manager
- Running tests in a specific branch
- Merging branches via the Test Manager
- Resolving conflicts
Creating a new branch via the Test Manager
Go to Branch baselines page by selecting it from the drop-down menu next to the Applitools logo.
Choose a branch which you want to copy baselines from.
You can do so by selecting the branch from the drop-down menu on the right side of the screen.
Select the baselines which you want to copy to the new branch by checking the checkbox next to their name and click the "Copy baselines to branch..." button.
In the "Copy baselines to branch" dialog, type a name for a new branch or select an existing one from the list and click the "Copy to branch" button.
Running tests in a specific branch
To run a test in a specific branch add the following line before eyes.open():
- Java:
eyes.setBranchName(<branch name>);
- Ruby:
eyes.branch_name = <branch name>
- Python:
eyes.branch_name = <branch name>
eyes.BranchName = <branch name>;
- JS:
eyes.setBranchName(<branch name>)
A "parent branch" can be configured in order to compare against an existing baseline in a different branch, in case a baseline cannot be found in the requested branch.
If not set, the parent branch will be "default". Explicitly setting an alternative parent branch can be done by adding the following line before eyes.open():
- Java:
eyes.setParentBranchName(<branch name>);
- Ruby:
eyes.parent_branch_name = <branch name>
- Python:
eyes.parent_branch_name = <branch name>
- DotNet:
eyes.ParentBranchName = <branch name>
- JS:
eyes.setParentBranchName(<branch name>);
The Behavior of a Comparison When Running a Test
- If the requested branch does not exist, it will be created.
- If the baseline exists in this branch, the test will be compared against it.
- If the baseline does not exist in this branch, it will look up for the baseline in the parent branch and compare against it (note that in order to create a baseline in the requested branch the test result must be resolved - either accepted or rejected - and saved).
- If the baseline does not exist in this branch or in the parent branch, a new baseline will be created in this branch.
Note: If you set a parent branch which does not exist, an exception will be thrown.
Merging branches via the Test Manager
Go to Compare & merge branches page by selecting it from the drop-down menu next to the Applitools logo.
Merging branches via the Test Manager
Go to Compare & merge branches page by selecting it from the drop-down menu next to the Applitools logo.
Select the source and target branches and click the "Compare" button.
If changes exist and there are no conflicts (discussed later in this article), choose the baselines you would like to merge (by checking the relevant checkboxes) and click the "Merge" button to merge the baselines from the source branch into the target branch.
A confirmation dialog will appear, click the "Yes" button to confirm merging.
Resolving conflicts
There are two reasons for conflicts:
- A conflict occurs when a mismatching test in the target branch was saved after running that test in the source branch.
- A conflict can also occur when successfully merging a source branch "B1" into the target branch, and then attempting to merge another source branch "B2" into the same target branch (since the target branch was changed due to the first merge).
All conflicts must be resolved before merging the source branch to the target branch.
To resolve a conflict a decision needs to be made - whether the source image should be taken as the baseline or the target image.
To resolve a conflict a decision needs to be made - whether the source image should be taken as the baseline or the target image.
Do so by clicking on one of the following buttons on the right side of the baseline row:
- Take source baseline
- Take target baseline
In addition to the screenshot, a baseline can also have an annotation (i.e., regions and remarks) attached to it.
In case the source image was decided as the baseline, another decision is required before merging - keeping the source annotations, replacing them with the annotations from the target or to keeping both annotations.
To do so, click on the "Compare and edit source baseline" button, located on the right side of the baseline row.
This will lead to the Compare baseline page.
To add the target annotations to source baseline click on the "Add target annotations to source" button.
To add the target annotations to source baseline click on the "Add target annotations to source" button.
To replace the target annotations with the source annotations, click the arrow next to "Add target annotations to source" button to open the menu and click on "Replace source annotations with target's".
Click the "Save" button to save changes.