Skip to content

Commit cc05317

Browse files
committed
Add properties argument (-pr)
1 parent 7cc5663 commit cc05317

File tree

6 files changed

+34
-23
lines changed

6 files changed

+34
-23
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ The tool build in java and requires minimal set of parameters the minimal comman
136136
+ `-rc` - Capture only a particular region of PDFs/Images. <br>
137137
**Example:** `-rc "200,500,1000,1000"` instructs ImageTester to only test region with: <br>
138138
+ x:200, y:500, with width:1000, height:1000
139+
+ `-pr` - Add properties to Eyes tests. Format is `key1:value1|key2:value2`.<br>
140+
Each property will have the format "key1:value1", and each subsequent format will be separated by a "|" character. <br>
141+
**Example:** `-pr "prop1:value1|prop2:value2|prop3:value3"` will add properties: <br>
142+
+ prop1, value1
143+
+ prop2, value2
144+
+ prop3, value3
139145

140146
### Using The Batch Mapper
141147
The Batch Mapper is a feature that allows you to specify tests from a CSV instead of supplying a path or file in the traditional way.

pom.xml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.applitools.imagetester</groupId>
66
<artifactId>ImageTester</artifactId>
7-
<version>3.5.7</version>
7+
<version>3.6.0</version>
88
<packaging>jar</packaging>
99
<properties>
1010
<maven.compiler.source>1.8</maven.compiler.source>
@@ -19,26 +19,6 @@
1919
</repositories>
2020

2121
<dependencies>
22-
<dependency>
23-
<groupId>com.applitools</groupId>
24-
<artifactId>eyes-universal-core-win</artifactId>
25-
<version>RELEASE</version>
26-
</dependency>
27-
<dependency>
28-
<groupId>com.applitools</groupId>
29-
<artifactId>eyes-universal-core-mac</artifactId>
30-
<version>RELEASE</version>
31-
</dependency>
32-
<dependency>
33-
<groupId>com.applitools</groupId>
34-
<artifactId>eyes-universal-core-linux</artifactId>
35-
<version>RELEASE</version>
36-
</dependency>
37-
<dependency>
38-
<groupId>com.applitools</groupId>
39-
<artifactId>eyes-universal-core-alpine</artifactId>
40-
<version>RELEASE</version>
41-
</dependency>
4222
<dependency>
4323
<groupId>com.applitools</groupId>
4424
<artifactId>eyes-universal-core-arm</artifactId>

src/main/java/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Manifest-Version: 1.0
22
Main-Class: com.applitools.imagetester.ImageTester
3-
Implementation-Version: 3.5.7
3+
Implementation-Version: 3.6.0
44

src/main/java/com/applitools/imagetester/ImageTester.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import com.applitools.imagetester.lib.Utils;
2727

2828
public class ImageTester {
29-
private static final String cur_ver = "3.5.7";
29+
private static final String cur_ver = "3.6.0";
3030

3131
public static void main(String[] args) {
3232

@@ -119,6 +119,7 @@ public static void main(String[] args) {
119119
config.setAccessibilityGraphicsRegions(cmd.getOptionValue("arg", null));
120120
config.setCaptureRegion(cmd.getOptionValue("rc", null));
121121
config.setMatchTimeout(cmd.getOptionValue("mt", null));
122+
config.setProperties(cmd.getOptionValue("pr", null));
122123

123124
// Full page for ac regions capability
124125
if (cmd.hasOption("arr") && config.accessibilityRegularTextRegions == null) {
@@ -242,6 +243,7 @@ private static void runTestWithBatchMapper(final Logger logger, final CommandLin
242243
currentConfiguration.shouldThrowException = cmd.hasOption("te");
243244
currentConfiguration.setCaptureRegion(cmd.getOptionValue("rc", null));
244245
currentConfiguration.setMatchTimeout(cmd.getOptionValue("mt", null));
246+
currentConfiguration.setProperties(cmd.getOptionValue("pr", null));
245247

246248
// Full page for ac regions capability
247249
if (cmd.hasOption("arr") && currentConfiguration.accessibilityRegularTextRegions == null) {
@@ -578,6 +580,11 @@ private static Options getOptions() {
578580
.hasArg()
579581
.argName("deviceNameArg")
580582
.build());
583+
options.addOption(Option.builder("pr")
584+
.longOpt("properties")
585+
.desc("Eyes Properties")
586+
.hasArgs()
587+
.build());
581588

582589

583590
EyesUtilitiesConfig.injectOptions(options);

src/main/java/com/applitools/imagetester/TestObjects/TestBase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public String name() {
5959

6060
public TestResults runSafe(Eyes eyes) {
6161
try {
62+
for(int i = 0; i < conf_.properties.length; i++) {
63+
eyes.addProperty(conf_.properties[i][0], conf_.properties[i][1]);
64+
}
6265
eyes.addProperty(FILE_NAME_PROP, file_.getName());
6366
TestResults res = run(eyes);
6467
Utils.handleResultsDownload(conf_.eyesUtilsConf, res);

src/main/java/com/applitools/imagetester/lib/Config.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class Config {
5454
public String matchTimeout;
5555
public String deviceName;
5656
public String regexFileNameFilter;
57+
public String[][] properties = null;
5758

5859
public void setViewport(String viewport) {
5960
if (viewport == null) return;
@@ -242,6 +243,20 @@ public void setAccessibilityGraphicsRegions(String accessibilityGraphicsRegions)
242243
}
243244
}
244245

246+
public void setProperties(String propArgument) {
247+
boolean isValidFormat = Arrays.stream(propArgument.split("\\|"))
248+
.allMatch(s -> s.matches("[^:]+:[^:]+"));
249+
250+
if (!isValidFormat) {
251+
throw new IllegalArgumentException("Argument properties (-pr) does not follow the "
252+
+ "'key:value' format for all segments separated by \"|\".");
253+
}
254+
255+
properties = Arrays.stream(propArgument.split("\\|"))
256+
.map(prop -> prop.split(":", 2))
257+
.toArray(String[][]::new);
258+
}
259+
245260
public void setMatchTimeout(String matchTimeout) {
246261
this.matchTimeout = matchTimeout;
247262
}

0 commit comments

Comments
 (0)