@@ -39,48 +39,101 @@ 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+ * [ ** Required** ] apiUrl - URL where backend is running. Example: "http://localhost:4200 "
45+ * [ ** Required** ] project - Project name or ID. Example: "003f5fcf-6c5f-4f1f-a99f-82a697711382"
46+ * [ ** Required** ] apiKey - User apiKey. Example: "F5Z2H0H2SNMXZVHX0EA4YQM1MGDD"
47+ * [ _ Optional_ ] branch - Current git branch. Example: "develop"
48+ * [ _ Optional_ ] enableSoftAssert - Log errors instead of exceptions. Default value is false
49+ * [ _ Optional_ ] ciBuildId - id of the build in CI system
50+ * [ _ Optional_ ] httpTimeoutInSeconds - define http socket timeout in seconds. Default value is 10 seconds
51+
52+ There are a few ways to provide those options
53+
54+ <details >
55+
56+ <summary >Create config with builder</summary >
4357
4458``` 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
59+ VisualRegressionTrackerConfig config = VisualRegressionTrackerConfig . builder()
60+ .apiUrl(" http://localhost:4200" )
61+ .apiKey(" F5Z2H0H2SNMXZVHX0EA4YQM1MGDD" )
62+ .project(" 003f5fcf-6c5f-4f1f-a99f-82a697711382" )
63+ .enableSoftAssert(true )
64+ .branchName(" develop" )
65+ .build();
66+ ```
67+
68+ </details >
69+
70+ <details >
71+
72+ <summary >Set environment variables</summary >
73+
74+ ```
75+ export VRT_APIURL=http://localhost:4200
76+ export VRT_APIKEY=F5Z2H0H2SNMXZVHX0EA4YQM1MGDD
77+ export VRT_PROJECT=003f5fcf-6c5f-4f1f-a99f-82a697711382
78+ export VRT_BRANCHNAME=develop
79+ export VRT_ENABLESOFTASSERT=true
80+ export VRT_CIBUILDID=40bdba4
81+ export VRT_HTTPTIMEOUTINSECONDS=15
6682
67- );
6883```
6984
70- * Create an instance of ` VisualRegressionTracker `
85+ </details >
86+
87+ <details >
88+
89+ <summary >Create vrt.json file in the root of the project</summary >
90+
91+ ``` json
92+ {
93+ "apiUrl" : " [http://162.243.161.172:4200](http://localhost:4200)" ,
94+ "project" : " 003f5fcf-6c5f-4f1f-a99f-82a697711382" ,
95+ "apiKey" : " F5Z2H0H2SNMXZVHX0EA4YQM1MGDD" ,
96+ "branchName" : " deveolop" ,
97+ "enableSoftAssert" : false ,
98+ "ciBuildId" : " 40bdba4"
99+ }
100+
101+ ```
102+
103+ </details >
104+
105+ > [ !NOTE]
106+ > Final values, that will be used by VisualRegressionTracker, will be resolved as following:
107+ > 1 . Check if it was provided while creating or building VisualRegressionTrackerConfig
108+ > 2 . If not, try to find the environment variable
109+ > 3 . Get it from the configuration file (if it exists)
110+
111+
112+
113+
114+ ### Create an instance of ` VisualRegressionTracker `
71115
72116``` java
73117VisualRegressionTracker visualRegressionTracker = new VisualRegressionTracker (config);
74118```
75119
76- * Take a screenshot as String in Base64 format
120+ or
121+
122+ ``` java
123+ VisualRegressionTracker visualRegressionTracker = new VisualRegressionTracker ();
124+ ```
125+
126+ > [ !TIP]
127+ > 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
128+
129+ ### Take a screenshot as String in Base64 format
77130
78131``` java
79132// Selenium example
80133String screenshotBase64 = ((TakesScreenshot ) driver). getScreenshotAs(OutputType . BASE64 );
81134```
82135
83- * Track image
136+ ### Track image
84137
85138Default options
86139
0 commit comments