json-schema-org / json-schema-org/JSON-Schema-Test-Suite
Revamped output testing
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 750
- Forks
- 307
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 24
Description
Following up on #247 and in light of @jdesrosiers' #652, I think we can do better for output tests.
The current test structure presents a JSON Schema that constrains several locations to specific values.
However, maybe a simpler approach (both to implement and write) would be just to have a series of JSON Pointers and the values that are expected to be in the output at those locations. For example, the above test file could be re-written as:
[
{
"description": "readOnly generates its value as an annotation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://json-schema.org/tests/content/draft2020-12/readOnly/0",
"readOnly": true
},
"tests": [
{
"description": "readOnly is true",
"data": 1,
"output": {
"basic": {
"/annotations/0/keywordLocation": "/readOnly",
"/annotations/0/absoluteKeywordLocation": "https://json-schema.org/tests/content/draft2020-12/readOnly/0#/readOnly",
"/annotations/0/instanceLocation": "",
"/annotations/0/annotation": true
}
}
}
]
}
]
As long as all of those locations in the output contain those values, it is considered valid.
There is one caveat that the current version of the test also enforces that the the errors property is disallowed when annotations is present, which is something that the spec requires, but the proposal can't cover that case. I'm open to options here if that's important to us.
Edit: I've since realized that the pointers need indices because annotations is an array. I'm not sure if we can specify that the first one needs to be a particular value. Items in the array could be in any order. Maybe the tests could be engineered so that it's the only expected item?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with output-tests/draft2020-12/content/readOnly.json and compare it with the proposed JSON Pointer structure, then review the constraints discussed in issues #247 and #652. Define how array ordering and the errors/annotations rule should be represented; the work is done when the output-test format can express the required assertions without losing those constraints.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json
- Domain
- testing
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100