From 9b401c65d1d506f1f55dd1ae3b72e9895b4adabe Mon Sep 17 00:00:00 2001 From: Oleg Ridchenko <73664101+oleg-rd@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:46:12 +0200 Subject: [PATCH 1/3] Updated configuration section --- README.md | 105 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 79 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 6a163d6..443ac7d 100644 --- a/README.md +++ b/README.md @@ -39,48 +39,101 @@ More info about https://jitpack.io/ ## Usage -* Create config +### Configuration +In order to initialize VisualRegressionTracker, following options should be defined: + * [**Required**] apiUrl - URL where backend is running. Example: "http://localhost:4200" + * [**Required**] project - Project name or ID. Example: "003f5fcf-6c5f-4f1f-a99f-82a697711382" + * [**Required**] apiKey - User apiKey. Example: "F5Z2H0H2SNMXZVHX0EA4YQM1MGDD" + * [_Optional_] branch - Current git branch. Example: "develop" + * [_Optional_] enableSoftAssert - Log errors instead of exceptions. Default value is false + * [_Optional_] ciBuildId - id of the build in CI system + * [_Optional_] httpTimeoutInSeconds - define http socket timeout in seconds. Default value is 10 seconds + + There are a few ways to provide those options + +
+ +Create config with builder ```java -VisualRegressionTrackerConfig config = new VisualRegressionTrackerConfig( - // apiUrl - URL where backend is running - "http://localhost:4200", - - // project - Project name or ID - "003f5fcf-6c5f-4f1f-a99f-82a697711382", - - // apiKey - User apiKey - "F5Z2H0H2SNMXZVHX0EA4YQM1MGDD", - - // branch - Current git branch - "develop", - - // enableSoftAssert - Log errors instead of exceptions - false, - - // ciBuildId - id of the build in CI system - "CI_BUILD_ID", - - // httpTimeoutInSeconds - define http socket timeout in seconds (default 10s) - 15 +VisualRegressionTrackerConfig config = VisualRegressionTrackerConfig.builder() + .apiUrl("http://localhost:4200") + .apiKey("F5Z2H0H2SNMXZVHX0EA4YQM1MGDD") + .project("003f5fcf-6c5f-4f1f-a99f-82a697711382") + .enableSoftAssert(true) + .branchName("develop") + .build(); +``` + +
+ +
+ +Set environment variables + +``` +export VRT_APIURL=http://localhost:4200 +export VRT_APIKEY=F5Z2H0H2SNMXZVHX0EA4YQM1MGDD +export VRT_PROJECT=003f5fcf-6c5f-4f1f-a99f-82a697711382 +export VRT_BRANCHNAME=develop +export VRT_ENABLESOFTASSERT=true +export VRT_CIBUILDID=40bdba4 +export VRT_HTTPTIMEOUTINSECONDS=15 -); ``` -* Create an instance of `VisualRegressionTracker` +
+ +
+ +Create vrt.json file in the root of the project + +```json +{ + "apiUrl": "[http://162.243.161.172:4200](http://localhost:4200)", + "project": "003f5fcf-6c5f-4f1f-a99f-82a697711382", + "apiKey": "F5Z2H0H2SNMXZVHX0EA4YQM1MGDD", + "branchName": "deveolop", + "enableSoftAssert": false, + "ciBuildId": "40bdba4" +} + +``` + +
+ +> [!NOTE] +> Final values, that will be used by VisualRegressionTracker, will be resolved as following: +> 1. Check if it was provided while creating or building VisualRegressionTrackerConfig +> 2. If not, try to find the environment variable +> 3. Get it from the configuration file (if it exists) + + + + +### Create an instance of `VisualRegressionTracker` ```java VisualRegressionTracker visualRegressionTracker = new VisualRegressionTracker(config); ``` -* Take a screenshot as String in Base64 format +or + +```java +VisualRegressionTracker visualRegressionTracker = new VisualRegressionTracker(); +``` + +> [!TIP] +> If config is not provided explicitly, it will be created based on the environment variables or configuration file. Please see [Configuration](README.md#configuration) section + +### Take a screenshot as String in Base64 format ```java // Selenium example String screenshotBase64 = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64); ``` -* Track image +### Track image Default options From 93fae37cc1c31e9fca4cd6470f0cc7e77591b381 Mon Sep 17 00:00:00 2001 From: Oleg Ridchenko <73664101+oleg-rd@users.noreply.github.com> Date: Thu, 13 Feb 2025 12:10:00 +0200 Subject: [PATCH 2/3] minor updates --- README.md | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 443ac7d..ac111f3 100644 --- a/README.md +++ b/README.md @@ -41,13 +41,14 @@ More info about https://jitpack.io/ ### Configuration In order to initialize VisualRegressionTracker, following options should be defined: - * [**Required**] apiUrl - URL where backend is running. Example: "http://localhost:4200" - * [**Required**] project - Project name or ID. Example: "003f5fcf-6c5f-4f1f-a99f-82a697711382" - * [**Required**] apiKey - User apiKey. Example: "F5Z2H0H2SNMXZVHX0EA4YQM1MGDD" - * [_Optional_] branch - Current git branch. Example: "develop" - * [_Optional_] enableSoftAssert - Log errors instead of exceptions. Default value is false - * [_Optional_] ciBuildId - id of the build in CI system - * [_Optional_] httpTimeoutInSeconds - define http socket timeout in seconds. Default value is 10 seconds + +* `apiUrl` (**Required**) - URL where backend is running. _Example_: "http://localhost:4200" +* `project` (**Required**) - Project name or ID. _Example_: "003f5fcf-6c5f-4f1f-a99f-82a697711382" +* `apiKey` (**Required**) - User apiKey. _Example_: "F5Z2H0H2SNMXZVHX0EA4YQM1MGDD" +* `branch` (Optional) - Current git branch. _Example_: "develop" +* `enableSoftAssert` (Optional) - Log errors instead of exceptions. Default value is false +* `ciBuildId` (Optional) - id of the build in CI system +* `httpTimeoutInSeconds` (Optional) - define http socket timeout in seconds. Default value is 10 seconds There are a few ways to provide those options @@ -104,11 +105,11 @@ export VRT_HTTPTIMEOUTINSECONDS=15 > [!NOTE] > Final values, that will be used by VisualRegressionTracker, will be resolved as following: -> 1. Check if it was provided while creating or building VisualRegressionTrackerConfig -> 2. If not, try to find the environment variable -> 3. Get it from the configuration file (if it exists) - +> 1. If explicitly set while creating `VisualRegressionTrackerConfig` - use this value +> 2. Use value from environment variable if it exists +> 3. Try to get it from the configuration file +
### Create an instance of `VisualRegressionTracker` @@ -126,6 +127,18 @@ VisualRegressionTracker visualRegressionTracker = new VisualRegressionTracker(); > [!TIP] > If config is not provided explicitly, it will be created based on the environment variables or configuration file. Please see [Configuration](README.md#configuration) section +
+ +### Start `VisualRegressionTracker` + +```java +visualRegressionTracker.start(); +``` + +At that point VisualRegressionTracker will try to create a new build for provided project. All of the subsequent tracked screenshots are going to be included in that build. + +
+ ### Take a screenshot as String in Base64 format ```java @@ -133,6 +146,8 @@ VisualRegressionTracker visualRegressionTracker = new VisualRegressionTracker(); String screenshotBase64 = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64); ``` +
+ ### Track image Default options @@ -158,3 +173,12 @@ visualRegressionTracker.track( .build() ); ``` + + +### Stop `VisualRegressionTracker` + +```java +visualRegressionTracker.stop(); +``` + +Should be called once current build should be considered as completed. From eca059c02871c99dce201a95fda51758e35e3c20 Mon Sep 17 00:00:00 2001 From: Oleg Ridchenko <73664101+oleg-rd@users.noreply.github.com> Date: Thu, 13 Feb 2025 12:13:49 +0200 Subject: [PATCH 3/3] typo fixed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac111f3..d96ef65 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ export VRT_HTTPTIMEOUTINSECONDS=15 "apiUrl": "[http://162.243.161.172:4200](http://localhost:4200)", "project": "003f5fcf-6c5f-4f1f-a99f-82a697711382", "apiKey": "F5Z2H0H2SNMXZVHX0EA4YQM1MGDD", - "branchName": "deveolop", + "branchName": "develop", "enableSoftAssert": false, "ciBuildId": "40bdba4" }