You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -301,9 +301,9 @@ public void supplyExternalData(final T data) {
301
301
302
302
Check **io.github.sskorol.testcases** package for more examples.
303
303
304
-
### JSON, CSVand YAML processors
304
+
### JSON, CSV, YAML and XLSX processors
305
305
306
-
Test data supplier supports JSON, CSVand YML data retrieval. Assuming you have the following resources:
306
+
Test data supplier supports JSON, CSV, YML and XLSX data retrieval. Assuming you have the following resources:
307
307
308
308
```csv
309
309
username,password
@@ -341,6 +341,13 @@ username,password
341
341
password: '123'
342
342
```
343
343
344
+
```csv
345
+
USERNAME PASSWORD
346
+
admin admin
347
+
sskorol password
348
+
guest 123
349
+
```
350
+
344
351
You can now map Java entities to these data sources using **@Source** annotation, which accepts either local file name
345
352
or URL:
346
353
@@ -375,12 +382,28 @@ public class User {
375
382
}
376
383
```
377
384
385
+
```java
386
+
@Data
387
+
@NoArgsConstructor
388
+
@Source(path="users.xlsx")
389
+
publicclassUser {
390
+
@Column(name="USERNAME", index=0)
391
+
privateString username;
392
+
393
+
@Column(name="PASSWORD", index=1)
394
+
privateString password;
395
+
}
396
+
```
397
+
378
398
In case if some Java field's name differs from its data source representation, you can assign a valid name via
379
399
**@FieldName** for CSV, **@SerializedName** for JSON and **@JsonProperty** for YML data type.
380
400
381
-
Note that local data sources must be located in a classpath.
401
+
Excel support is experimental. [ZeroCell](https://github.com/creditdatamw/zerocell) library based on [Apache POI](https://github.com/apache/poi) is used here to simplify corresponding files processing.
402
+
So feel free to check their API and supported annotations. However, in terms of fields' mapping, you can use **Column**.
403
+
404
+
Note that local data sources must be located in a classpath. You usually use **resources** folder for that.
382
405
383
-
Then in **DataSupplier** you can call special **TestDataReader** builder to retrieve data from CSV, JSONor YML data source.
406
+
Then in **DataSupplier** you can call special **TestDataReader** builder to retrieve data from CSV, JSON, YML or XLSX data source.
384
407
See javadocs to get more details.
385
408
386
409
```java
@@ -404,6 +427,13 @@ public StreamEx<User> getUsers() {
0 commit comments