Skip to content

Commit 66d5572

Browse files
Michael HallikMichael Hallik
authored andcommitted
feat: change default behavior of fail_on_errors and add roadmap and demo suite
1 parent 270a13d commit 66d5572

File tree

86 files changed

+776
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+776
-73
lines changed

CHANGELOG.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,62 @@ All notable changes to the project will be documented in this file.
1212
- Use Poetry for dependency and release management.
1313

1414
## [1.0.1] - 2025-06-09
15-
- Refactor: simplify the __init_() method of class XmlValidator
15+
- Refactor: simplify the __init_() method of class XmlValidator
16+
17+
## [2.0.0] - 2025-06-14
18+
19+
### Breaking changes
20+
21+
- Changed default behavior of the `fail_on_errors` setting.
22+
- When using the `Validate Xml Files` keyword, test cases that detect validation errors (of any kind) will have FAIL status.
23+
- Previously, test cases received a PASS status, even when validation errors were found, unless `fail_on_errors=True` was explicitly set.
24+
- This change improves alignment with common validation expectations and was motivated by user feedback.
25+
- To preserve the old behavior, explicitly set `fail_on_errors=False` either during library import or per keyword call:
26+
27+
```robot
28+
Library XmlValidator fail_on_errors=False
29+
```
30+
31+
Or:
32+
33+
```robot
34+
Validate Xml Files path/to/file.xml fail_on_errors=False
35+
```
36+
37+
Note:
38+
39+
The library's batch validation behavior remains unchanged. That is, `fail_on_errors=True` does *not* short-circuit the validation process in any way.
40+
41+
For example
42+
- If you validate fifteen XML files and five of them contain schema violations or other errors, all files will still be processed.
43+
- Errors are simply collected throughout the run and reported collectively, only after the final file has been (fully) processed.
44+
- The test case will fail (assuming `fail_on_errors=True`) only after all files have been checked, ensuring comprehensive diagnostics.
45+
46+
### Added
47+
48+
- Support for setting `fail_on_errors` also at the *library import level*
49+
- Applies to all calls to `Validate Xml Files` unless explicitly overridden during keyword call (see also earlier/above).
50+
- Improves usability and test readability.
51+
52+
- New Robot Framework demo test suite containing 8 self-contained test cases.
53+
- Demonstrates key features:
54+
- Single and batch XML validation
55+
- Schema matching by filename and namespace
56+
- Custom error facets
57+
- Malformed XML handling
58+
- XSD includes/imports
59+
- CSV export
60+
- Serves as a quickstart reference for users exploring the library.
61+
62+
- `ROADMAP.md` to document planned features and/or improvements.
63+
64+
### Changed
65+
66+
- Integration test suite updated to support and validate the new `fail_on_errors` behavior.
67+
- Tests now reflect expected `FAIL` or `PASS` statuses depending on configuration.
68+
- Verifies both default (library-level) and keyword-level overrides.
69+
- Minor changes in the Robot Framework logging (based on user feedback).
70+
- Changed some from level=WARN to level=INFO.
71+
- Some got commented out.
72+
- Some indentation changes as well.
73+
- Changed documentation (READEME.md, keyword documentation, etc.) to reflect additions and changes in this version.

README.md

Lines changed: 92 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,26 @@
2424
- [Examples](#examples)
2525
- [Using a preloaded schema](#using-a-preloaded-schema)
2626
- [Defer schema loading to the test case(s)](#defer-schema-loading-to-the-test-cases)
27-
- [Importing with preloaded XSD that requires a base\_url](#importing-with-preloaded-xsd-that-requires-a-base_url)
28-
- [Importing with custom error\_facets](#importing-with-custom-error_facets)
27+
- [Importing with preloaded XSD that requires a `base_url`](#importing-with-preloaded-xsd-that-requires-a-base_url)
28+
- [Importing with custom `error_facets`](#importing-with-custom-error_facets)
29+
- [Importing with \`fail\_on\_errors=True](#importing-with-fail_on_errorstrue)
2930
- [Further examples](#further-examples)
3031
- [Using the library](#using-the-library)
3132
- [Keyword overview](#keyword-overview)
32-
- [Error collection](#error-collection)
33+
- [Error collection](#error-collection)
34+
- [Batch mode](#batch-mode)
35+
- [Single file mode](#single-file-mode)
36+
- [Test case status - fail\_on\_error](#test-case-status---fail_on_error)
37+
- [Dyanmic XSD resolution](#dyanmic-xsd-resolution)
38+
- [Error collection](#error-collection-1)
3339
- [XSD Schema violations.](#xsd-schema-violations)
3440
- [Malformed XML](#malformed-xml)
3541
- [File-level issues](#file-level-issues)
3642
- [Final note on error collection](#final-note-on-error-collection)
3743
- [Keyword documentation](#keyword-documentation)
3844
- [Keyword example usage](#keyword-example-usage)
3945
- [A few basic examples](#a-few-basic-examples)
46+
- [Demo test suite file as examples](#demo-test-suite-file-as-examples)
4047
- [Integration tests as examples](#integration-tests-as-examples)
4148
- [Example console output](#example-console-output)
4249
- [Example CSV output](#example-csv-output)
@@ -58,6 +65,8 @@
5865
- [Continuous Integration \& GitHub templates](#continuous-integration--github-templates)
5966
- [Class architecture (Simplified)](#class-architecture-simplified)
6067
- [Project Structure](#project-structure)
68+
- [Changelog](#changelog)
69+
- [Roadmap](#roadmap)
6170
- [License](#license)
6271
- [Author](#author)
6372

@@ -130,11 +139,12 @@ See the [Robot Framework Library Scope docs](https://robotframework.org/robotfra
130139

131140
### Library arguments
132141

133-
| Argument | Type | Required? | Description |
134-
|----------------|-------------|-----------|------------------------------------------------------------------------------------|
135-
| `xsd_path` | `str` | No | Path to an XSD file or folder to preload during initialization. In case of a folder, the folder must hold one file only. |
136-
| `base_url` | `str` | No | Base path used to resolve includes/imports within the provided XSD schema. |
137-
| `error_facets` | `list[str]` | No | The attributes of validation errors to collect and report (e.g., `path`, `reason`) |
142+
| Argument | Type | Required? | Description | Default |
143+
|-----------------|-------------|-----------|------------------------------------------------------------------------------------------------------------------------|-----------------|
144+
| `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 |
138148

139149
### Examples
140150

@@ -151,7 +161,7 @@ Library xmlvalidator xsd_path=path/to/schema.xsd
151161
Library xmlvalidator
152162
```
153163

154-
#### Importing with preloaded XSD that requires a base_url
164+
#### Importing with preloaded XSD that requires a `base_url`
155165

156166
```robotframework
157167
Library xmlvalidator xsd_path=path/to/schema_with_include.xsd
@@ -160,7 +170,7 @@ Library xmlvalidator xsd_path=path/to/schema_with_include.xsd
160170

161171
Use `base_url` when your XSD uses `<xs:include>` or `<xs:import>` with relative paths.
162172

163-
#### Importing with custom error_facets
173+
#### Importing with custom `error_facets`
164174

165175
Use the `error_facets` argument to control which attributes of detected errors will be collected and reported.
166176

@@ -179,6 +189,21 @@ Library xmlvalidator xsd_path=schemas/schema.xsd
179189
... error_facets=value, namespaces
180190
```
181191

192+
#### Importing with `fail_on_errors=True
193+
194+
The fail_on_errors argument controls whether a test case should fail if XML validation errors are detected.
195+
196+
It defaults to True.
197+
198+
The library's batch validation behavior remains unchanged. That is, `fail_on_errors=True` does *not* short-circuit the validation process in any way.
199+
200+
Set `fail_on_errors=False` to log validation issues without failing the test. This is useful for:
201+
202+
- Non-blocking checks in dashboards or QA reports.
203+
- Legacy or transitional systems where some invalid files are expected.
204+
- Schema discovery or diagnostics, where conformance isn’t yet enforced.
205+
- Soft rollout of stricter validation rules, allowing time to adapt.
206+
182207
#### Further examples
183208

184209
See also the [library initialization Robot test file](test/integration/01_library_initialization.robot).
@@ -189,39 +214,63 @@ See also the [library initialization Robot test file](test/integration/01_librar
189214

190215
### Keyword overview
191216

192-
| Keyword | Description |
193-
|--------------------------|-------------|
217+
Thi section merely provides a short summary of the library's capabilities.
218+
219+
For more details, please see the [keyword documentation](https://michaelhallik.github.io/robotframework-xmlvalidator/XmlValidator.html).
220+
221+
| Keyword | Description |
222+
|--------------------------|---------------------------------------------------------------------|
194223
| `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`) |
201230

202231
The main keyword is `Validate Xml Files`. The other keywords are convenience/helper functions, e.g. 'Reset Error Facets'.
203232

233+
#### Error collection
234+
204235
The `Validate Xml Files` validates one or more XML files against one or more XSD schema files and collects and reports all encountered errors.
205236

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.
207238

208239
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.
209240

210-
When operating in batch mode, the `Validate Xml Files` keyword always validates the entire set of passed XML files.
241+
#### Batch mode
211242

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).
213246

214247
In that fashion the keyword works through the entire set of files.
215248

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.
217250

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.
219255

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
221257

222258
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.
223259

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).
225274

226275
### Error collection
227276

@@ -306,9 +355,9 @@ General errors that do not pertain to syntax or schema issues:
306355

307356
#### Final note on error collection
308357

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.
310359

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).
312361

313362
### Keyword documentation
314363

@@ -357,6 +406,10 @@ Validate Folder With Multiple Schemas By File Name
357406
Validate Xml Files ${FOLDER_MULTIPLE_XML_XSD_FN} xsd_search_strategy=by_file_name
358407
```
359408

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+
360413
#### Integration tests as examples
361414

362415
Note that the [integration test](test/integration) folder contains seven Robot Framework test suite files.
@@ -745,6 +798,18 @@ requirements.txt # Requirements file for users (pip)
745798

746799
---
747800

801+
## Changelog
802+
803+
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+
748813
## License
749814

750815
Licensed under the Apache License 2.0. See [LICENSE](LICENSE).

ROADMAP.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Project roadmap
2+
3+
This document outlines planned features and/or ideas for the future development of the `robotframework-xmlvalidator` library.
4+
5+
This roadmap is aspirational and may evolve based on user feedback input and practical constraints.
6+
7+
---
8+
9+
## In progress / near-term
10+
11+
-
12+
13+
---
14+
15+
## Planned / future
16+
17+
-
18+
19+
---
20+
21+
## Community wishlist / open for discussion
22+
23+
-
24+
25+
---
26+
27+
## Ideas
28+
- Support for separate error facets for malformed XML errors vs. XSD violation errors.
29+
- XSD 1.1 support using XMLSchema 1.1 features (e.g., assertions, conditional types).
30+
- Explicit validation of XSD schemas using W3C meta-schema.
31+
- Flexible handling of wildcard elements (`<xs:any>`), with support for:
32+
- `strict`: must be validatable
33+
- `lax`: validate if possible
34+
- `skip`: accept without validation
35+
- Support for additional schema types (e.g., RelaxNG, Schematron).
36+
- Optional CLI runner for validation outside of Robot Framework.
37+
- Export error details to more formats (e.g. JSON, XML).
38+
- Enbed error collection as HTML tables in the log file (inline validation summaries).
39+
- Built-in diffs between schema versions.
40+
- GUI frontend for non-technical users.
41+
42+
---
43+
44+
Last updated: 2025-06-13
45+
46+
> Want to contribute or suggest a feature? Feel free to open an issue or join the discussion.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# General.
22
[tool.poetry]
33
name = "robotframework-xmlvalidator"
4-
version = "1.0.1"
4+
version = "2.0.0a1"
55
description = "A Robot Framework test library for validating XML files against XSD schemas"
66
authors = ["Michael Hallik <hallik.michael@gmail.com>"]
77
license = "Apache-2.0"

0 commit comments

Comments
 (0)