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
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -266,7 +266,7 @@ Actually, almost anything goes:
266
266
267
267
#### Test case status - fail_on_error
268
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.
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 status will always be PASS, regardless whether errors were collected or not.
Copy file name to clipboardExpand all lines: src/xmlvalidator/XmlValidator.py
+68-48Lines changed: 68 additions & 48 deletions
Original file line number
Diff line number
Diff line change
@@ -98,10 +98,10 @@ class XmlValidator:
98
98
99
99
When operating in batch mode, the ``Validate Xml Files`` keyword
100
100
always validates the entire set of passed XML files. That is, when
101
-
it encounters an error in a file, it does not simply fail. Rather,
102
-
it collects the error details (as determined by the error_facets
103
-
arg) and then continues validating the current file as well as any
104
-
subsequent file(s).
101
+
it encounters an error in a file, it does not simply then fail.
102
+
Rather, it collects the error details (as determined by the
103
+
error_facets arg) and then continues validating the current file as
104
+
well as any subsequent file(s).
105
105
106
106
In that fashion the keyword works through the entire set of files.
107
107
@@ -158,12 +158,14 @@ class XmlValidator:
158
158
- Namespace errors.
159
159
- Etc.
160
160
161
-
- Captures malformed XML.
161
+
- Captures malformed XML (e.g. missing closing tag, encoding
162
+
issues).
162
163
- Handles edge cases like empty files or XML files that could not be
163
164
matched to an XSD schema file.
164
-
- Does not fail on errors, but collects encountered errors in all
165
-
files and reports them in a structured format in the console and
166
-
RF log.
165
+
- Does not immediately fail on errors, but collects encountered all
166
+
errors in all files and reports them in a structured format in the
167
+
console and RF log. Only *then* fails (assuming one or more
168
+
errors have been collected).
167
169
- Supports specifying the details that should be collected for
168
170
encountered errors.
169
171
- Optionally exports the error report to a CSV file, providing the
@@ -236,23 +238,13 @@ class XmlValidator:
236
238
Enables resolution of schema imports/includes via a custom base URL,
237
239
via the ``base_url`` arg.
238
240
239
-
Use ``base_url`` when your XSD uses <xs:include> or <xs:import> with
240
-
relative paths.
241
+
Use ``base_url`` when your XSD uses ``<xs:include>`` or ``<xs:import>``
242
+
with relative paths.
241
243
242
244
You can pass ``base_url`` with the library import (together with
243
245
passing ``xsd_path``) and/or when calling ``Validate Xml Files``
244
246
with ``xsd_path``.
245
247
246
-
** Optional test case fail **
247
-
248
-
The ``Validate Xml Files`` keyword collects one or more errors for
249
-
one or more XML files. As mentioned earlier, the keyword is designed
250
-
so as to not fail upon encountering errors.
251
-
252
-
However, in case you want your test case to fail when one or more
253
-
errors have been detected, you can use the ``fail_on_errors`` (bool)
254
-
argument to make it so. It defaults to ${False}.
255
-
256
248
**Basic usage examples**
257
249
258
250
For a comprehensive set of example test cases, please see the
@@ -266,6 +258,18 @@ class XmlValidator:
266
258
It further contains a detailed instruction on
267
259
`how to run Robot Framework tests <https://github.com/MichaelHallik/robotframework-xmlvalidator/blob/main/test/_doc/integration/README.md>`_.
268
260
261
+
Finally, the repo also contains a `demo test suite file <https://github.com/MichaelHallik/robotframework-xmlvalidator/blob/main/test/demo/demo.robot>`_ containing
262
+
eight self-contained test cases to demonstrates the following features:
263
+
264
+
- Single and batch XML validation
265
+
- Schema matching by filename and namespace
266
+
- Custom error facets
267
+
- Malformed XML handling
268
+
- XSD includes/imports
269
+
- CSV export
270
+
271
+
A test suite file may look like the following:
272
+
269
273
.. code:: robotframework
270
274
271
275
*** Settings ***
@@ -361,21 +365,8 @@ class XmlValidator:
361
365
[ WARN ] XML is invalid:
362
366
[ WARN ] Error #0:
363
367
[ WARN ] reason: No matching XSD found for: no_xsd_match_2.xml.
364
-
Validation errors exported to 'C:\\test\\01_Advanced_Validation\\errors_2025-03-29_13-54-46-552150.csv'.
365
-
Total_files validated: 11.
366
-
Valid files: 6.
367
-
Invalid files: 5
368
-
01 Advanced Validation:: Demo XML validation | PASS |
See the introduction for more details on the purpose and usage
488
482
of error facets.
483
+
484
+
``fail_on_error``
485
+
486
+
The ``fail_on_errors`` argument controls whether a test case
487
+
should fail if one or more XML validation errors are detected.
488
+
It defaults to True. A test case that has resulted in the
489
+
collection of one or more errors (of whatever type) will then
490
+
receive a status of FAIL.
491
+
492
+
You can use the ``fail_on_errors`` argument to change this
493
+
default behaviour. When set to False, a test cases's status will
494
+
always be PASS, regardless whether errors were collected or not.
495
+
496
+
This may be useful for:
497
+
498
+
- Non-blocking checks in dashboards or QA reports.
499
+
- Legacy or transitional systems where some invalid files are expected.
500
+
- Schema discovery or diagnostics, where conformance isn’t yet enforced.
501
+
- Soft rollout of stricter validation rules, allowing time to adapt.
502
+
503
+
Note that with ``fail_on_error=True`` the library's batch
504
+
validation behavior remains unchanged by the latter. That is,
505
+
fail_on_errors=True does not short-circuit the validation
506
+
process in any way.
489
507
490
508
**Examples**
491
509
@@ -531,6 +549,8 @@ def __init__(
531
549
For more examples see the project's
532
550
`Robot Framework integration test suite <https://github.com/MichaelHallik/robotframework-xmlvalidator/blob/main/test/integration/01_library_initialization.robot>`_.
533
551
552
+
And also the `demo test suite file <https://github.com/MichaelHallik/robotframework-xmlvalidator/blob/main/test/demo/demo.robot>`_.
0 commit comments