Skip to content

Commit 833f16a

Browse files
authored
Readme update (#111)
* Updated configuration section * minor updates * typo fixed
1 parent 8948b82 commit 833f16a

File tree

1 file changed

+103
-26
lines changed

1 file changed

+103
-26
lines changed

README.md

+103-26
Original file line numberDiff line numberDiff line change
@@ -39,48 +39,116 @@ More info about https://jitpack.io/
3939

4040
## Usage
4141

42-
* Create config
42+
### Configuration
43+
In order to initialize VisualRegressionTracker, following options should be defined:
44+
45+
* `apiUrl` (**Required**) - URL where backend is running. _Example_: "http://localhost:4200"
46+
* `project` (**Required**) - Project name or ID. _Example_: "003f5fcf-6c5f-4f1f-a99f-82a697711382"
47+
* `apiKey` (**Required**) - User apiKey. _Example_: "F5Z2H0H2SNMXZVHX0EA4YQM1MGDD"
48+
* `branch` (Optional) - Current git branch. _Example_: "develop"
49+
* `enableSoftAssert` (Optional) - Log errors instead of exceptions. Default value is false
50+
* `ciBuildId` (Optional) - id of the build in CI system
51+
* `httpTimeoutInSeconds` (Optional) - define http socket timeout in seconds. Default value is 10 seconds
52+
53+
There are a few ways to provide those options
54+
55+
<details>
56+
57+
<summary>Create config with builder</summary>
4358

4459
```java
45-
VisualRegressionTrackerConfig config = new VisualRegressionTrackerConfig(
46-
// apiUrl - URL where backend is running
47-
"http://localhost:4200",
48-
49-
// project - Project name or ID
50-
"003f5fcf-6c5f-4f1f-a99f-82a697711382",
51-
52-
// apiKey - User apiKey
53-
"F5Z2H0H2SNMXZVHX0EA4YQM1MGDD",
54-
55-
// branch - Current git branch
56-
"develop",
57-
58-
// enableSoftAssert - Log errors instead of exceptions
59-
false,
60-
61-
// ciBuildId - id of the build in CI system
62-
"CI_BUILD_ID",
63-
64-
// httpTimeoutInSeconds - define http socket timeout in seconds (default 10s)
65-
15
60+
VisualRegressionTrackerConfig config = VisualRegressionTrackerConfig.builder()
61+
.apiUrl("http://localhost:4200")
62+
.apiKey("F5Z2H0H2SNMXZVHX0EA4YQM1MGDD")
63+
.project("003f5fcf-6c5f-4f1f-a99f-82a697711382")
64+
.enableSoftAssert(true)
65+
.branchName("develop")
66+
.build();
67+
```
68+
69+
</details>
70+
71+
<details>
72+
73+
<summary>Set environment variables</summary>
74+
75+
```
76+
export VRT_APIURL=http://localhost:4200
77+
export VRT_APIKEY=F5Z2H0H2SNMXZVHX0EA4YQM1MGDD
78+
export VRT_PROJECT=003f5fcf-6c5f-4f1f-a99f-82a697711382
79+
export VRT_BRANCHNAME=develop
80+
export VRT_ENABLESOFTASSERT=true
81+
export VRT_CIBUILDID=40bdba4
82+
export VRT_HTTPTIMEOUTINSECONDS=15
6683
67-
);
6884
```
6985

70-
* Create an instance of `VisualRegressionTracker`
86+
</details>
87+
88+
<details>
89+
90+
<summary>Create vrt.json file in the root of the project</summary>
91+
92+
```json
93+
{
94+
"apiUrl": "[http://162.243.161.172:4200](http://localhost:4200)",
95+
"project": "003f5fcf-6c5f-4f1f-a99f-82a697711382",
96+
"apiKey": "F5Z2H0H2SNMXZVHX0EA4YQM1MGDD",
97+
"branchName": "develop",
98+
"enableSoftAssert": false,
99+
"ciBuildId": "40bdba4"
100+
}
101+
102+
```
103+
104+
</details>
105+
106+
> [!NOTE]
107+
> Final values, that will be used by VisualRegressionTracker, will be resolved as following:
108+
> 1. If explicitly set while creating `VisualRegressionTrackerConfig` - use this value
109+
> 2. Use value from environment variable if it exists
110+
> 3. Try to get it from the configuration file
111+
112+
<br />
113+
114+
115+
### Create an instance of `VisualRegressionTracker`
71116

72117
```java
73118
VisualRegressionTracker visualRegressionTracker = new VisualRegressionTracker(config);
74119
```
75120

76-
* Take a screenshot as String in Base64 format
121+
or
122+
123+
```java
124+
VisualRegressionTracker visualRegressionTracker = new VisualRegressionTracker();
125+
```
126+
127+
> [!TIP]
128+
> 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
129+
130+
<br />
131+
132+
### Start `VisualRegressionTracker`
133+
134+
```java
135+
visualRegressionTracker.start();
136+
```
137+
138+
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.
139+
140+
<br />
141+
142+
### Take a screenshot as String in Base64 format
77143

78144
```java
79145
// Selenium example
80146
String screenshotBase64 = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64);
81147
```
82148

83-
* Track image
149+
<br />
150+
151+
### Track image
84152

85153
Default options
86154

@@ -105,3 +173,12 @@ visualRegressionTracker.track(
105173
.build()
106174
);
107175
```
176+
177+
178+
### Stop `VisualRegressionTracker`
179+
180+
```java
181+
visualRegressionTracker.stop();
182+
```
183+
184+
Should be called once current build should be considered as completed.

0 commit comments

Comments
 (0)