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
|`xsd_path`|`str`| No | Path to an XSD file/folder to preload during initialization. In case of a folder, the folder must hold one file only. | None |
145
+
|`base_url`|`str`| No | Base path used to resolve includes/imports within the provided XSD schema. | None |
146
+
|`error_facets`|`list[str]`| No | The attributes of validation errors to collect and report (e.g., `path`, `reason`) |[path, reason]|
147
+
|`fail_on_error`|`bool`| No | Whether to fail the test case if one or more XML validation errors are found. Can be overridden per keyword call. | True |
|`Validate Xml Files`| Validate one or more XML files against one or more XSD schema files |
195
-
|`Reset Schema`| Clear the currently loaded XSD schema |
196
-
|`Reset Errors`| Clear the set of collected errors |
197
-
|`Get Schema`| Get the current schema name or object |
198
-
|`Log Schema`| Log the currently loaded schema |
199
-
|`Get Error Facets`| Returns a list of the currently active error facets |
200
-
|`Reset Error Facets`| Reset the error facets to default (`path`, `reason`) |
224
+
|`Reset Schema`| Clear the currently loaded XSD schema |
225
+
|`Reset Errors`| Clear the set of collected errors |
226
+
|`Get Schema`| Get the current schema name or object |
227
+
|`Log Schema`| Log the currently loaded schema |
228
+
|`Get Error Facets`| Returns a list of the currently active error facets |
229
+
|`Reset Error Facets`| Reset the error facets to default (`path`, `reason`) |
201
230
202
231
The main keyword is `Validate Xml Files`. The other keywords are convenience/helper functions, e.g. 'Reset Error Facets'.
203
232
233
+
#### Error collection
234
+
204
235
The `Validate Xml Files` validates one or more XML files against one or more XSD schema files and collects and reports all encountered errors.
205
236
206
-
The type of error that the keyword can detect is not limited to XSD violations, but may also pertain to malformed XML files (e.g. parse errors), empty files, unmatched XML files (no XSD match found), etc.
237
+
The type of error that the keyword can detect is not limited to XSD violations, but may also pertain to malformed XML files, empty files, unmatched XML files (no XSD match found), etc.
207
238
208
239
Errors that result from malformed XML files or from XSD violations support detailed error reporting. Using the `error_facets` argument you may specify the details the keyword should collect and report about captured errors.
209
240
210
-
When operating in batch mode, the `Validate Xml Files` keyword always validates the entire set of passed XML files.
241
+
#### Batch mode
211
242
212
-
That is, when it encounters an error in a file, it does not fail. Rather, it collects the error details (as determined by the `error_facets` arg) and then continues validating the current file as well as any subsequent file(s).
243
+
The `Validate Xml Files` keyword always validates the entire set of passed XML files.
244
+
245
+
That is, when it encounters an error in a file, it does not fail and stop execution. Rather, it collects the error details (as determined by the `error_facets` arg) and then continues validating the current file as well as any subsequent file(s).
213
246
214
247
In that fashion the keyword works through the entire set of files.
215
248
216
-
Once all files are processed it will log a summary of the test run and then proceed to report all collected errors in the console, in the RF log and, optionally, in the form of a CSV file.
249
+
Once *all* files are processed it will log a summary of the test run and then proceed to report all collected errors in the console, in the RF log and, optionally, in the form of a CSV file.
217
250
218
-
However, in case you want your test case to fail when one or more errors have been detected, you can use the ``fail_on_errors`` (bool) argument to make it so. It defaults to False. When setting it to True, the keyword will still check each XML file (and collect possible errors), but after it has thus processed the batch, it will fail if one or more errors will have been detected.
251
+
For example:
252
+
- If you validate fifteen XML files and five of them contain schema violations or other errors, all files will still be processed.
253
+
- Errors are simply collected throughout the run and reported collectively, only after the final file has been (fully) processed.
254
+
- The test case will fail (assuming `fail_on_errors=True`) only after all files have been checked, ensuring comprehensive diagnostics.
219
255
220
-
The keyword further supports the dynamic matching (i.e. pairing) of XML and XSD files, using either a 'by filename' or a 'by namespace' strategy. That means you can simply pass the paths to a folder containing XML files and to a folder containing XSD files and the keyword will determine which XSD schema file to use for each XML file. If the XML and XSD files reside in the same folder, you only have to pass one folder path. When no matching XSD schema could be identified for an XML file, this will be integrated into the mentioned summary and error reporting (the keyword will not fail).
256
+
#### Single file mode
221
257
222
258
Of course, you may also refer to specific XML/XSD files (instead of to folders). In that case, no matching will be attempted, but the keyword will simply try to validate the specified XML file against the specified XSD file.
223
259
224
-
For more details, please see the [keyword documentation](https://michaelhallik.github.io/robotframework-xmlvalidator/XmlValidator.html).
260
+
Actually, almost anything goes:
261
+
262
+
- one folder with: one or more XML files and one or more XSD files
263
+
- one folder with one or more XML files and another folder with one or more XSD files
264
+
- one folder with one or more XML files and a single XSD file
265
+
- a single XML file and a sigle XSD file
266
+
267
+
#### Test case status - fail_on_error
268
+
269
+
A test case that has resulted in the collection of one or more errors (of whatever type) will receive a status of FAIL. You can use the ``fail_on_errors`` (bool) argument to change this default behaviour. When set to `False`, the test cases's will always be PASS, regardless whether errors were collected or not.
270
+
271
+
#### Dyanmic XSD resolution
272
+
273
+
The keyword further supports the dynamic matching (i.e. pairing) of XML and XSD files, using either a 'by filename' or a 'by namespace' strategy. That means you can simply pass the paths to a folder containing XML files and to a folder containing XSD files and the keyword will determine which XSD schema file to use for each XML file. If the XML and XSD files reside in the same folder, you only have to pass one folder path. When no matching XSD schema could be identified for an XML file, this will be integrated into the mentioned summary and error reporting (the keyword will not fail).
225
274
226
275
### Error collection
227
276
@@ -306,9 +355,9 @@ General errors that do not pertain to syntax or schema issues:
306
355
307
356
#### Final note on error collection
308
357
309
-
On account of the purpose of this library, all encountered errors (regardless the involved types) are collected and reported. The validator analyzes all files, collects encountered errors (if any) and, finally, reports the results of the run in the console and in the Robot Framework log
358
+
On account of the purpose of this library, all encountered errors (regardless the involved types) are collected and reported. The validator analyzes all files, collects encountered errors (if any) and, finally, reports the results of the run in the console and in the Robot Framework log.
310
359
311
-
If you want the test run to receive a FAIL status when, at the end of test run, one or more errors have been found, then set: `fail_on_errors=True`.
360
+
Every test case in which one or more errors have been collected, will receive status FAIL unless `fail_on_errors=True` (see earlier explanations).
312
361
313
362
### Keyword documentation
314
363
@@ -357,6 +406,10 @@ Validate Folder With Multiple Schemas By File Name
357
406
Validate Xml Files ${FOLDER_MULTIPLE_XML_XSD_FN} xsd_search_strategy=by_file_name
358
407
```
359
408
409
+
#### Demo test suite file as examples
410
+
411
+
See the [demo test suite](test/demo/demo.robot) for a demo test suite that demonstrates the most important features of the library in a concise fashion.
412
+
360
413
#### Integration tests as examples
361
414
362
415
Note that the [integration test](test/integration) folder contains seven Robot Framework test suite files.
For a list of changes across versions, including recent behavioral changes in validation logic, see the [CHANGELOG](https://github.com/MichaelHallik/robotframework-xmlvalidator/blob/main/CHANGELOG.md).
804
+
805
+
---
806
+
807
+
## Roadmap
808
+
809
+
See the [project roadmap](ROADMAP.md) for upcoming features and ideas.
810
+
811
+
---
812
+
748
813
## License
749
814
750
815
Licensed under the Apache License 2.0. See [LICENSE](LICENSE).
0 commit comments