Skip to content

Commit 6e8227c

Browse files
committed
added IssueTest docs to contribution guidelines
1 parent 8a7e642 commit 6e8227c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

CONTRIBUTING.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,37 @@ Contributing guidelines
44
Submitting bugreports
55
---------------------
66

7+
Though any kind of feedback, feature request and bugreport is appreciated, I would more prefer if you would send a proper
8+
pull request with a failing test in case you find a bug in the library.
79

10+
Currently there is a simple mechanism in the integration tests to make it easy to add new tests. Using this is especially
11+
preferred if your bugreport is related to a complex schema or multiple schemas. There is no need to dig into the java code,
12+
you only have to create a few new files in the repo (but you will have to run the tests - see the build instructions below).
13+
14+
Steps:
15+
* create an issue, just to get an issue number
16+
* fork the repository
17+
* in your fork, create a directory under the `tests/src/test/resources/org/everit/json/schema/issues/` directory (for example `issue42` )
18+
* in this directory create a `schema.json` file with your JSON Schema document that is not handled correctly
19+
* in the same directory create a `subject-valid.json` file, which is a JSON document, and you expect that document to pass
20+
the validation, but due to a bug it fails with a `ValidationException`
21+
* if you have a JSON document that you expect to be invalid, but it passes the validation, then you should name this file `subject-invalid.json`.
22+
It will mean that for the test suite that an expected ValidationException is not thrown.
23+
* you can create both the `subject-valid.json` and `subject-invalid.json` test files if you find it needed
24+
25+
26+
Remote schema loading:
27+
If your testcase has anything to do with remote schemas, then
28+
* you can put those schemas under the `yourIssueDir/remotes/` directory
29+
* the `yourIssueDir/remotes/` directory will act as the document root of a HTTP server during test execution
30+
* this HTTP server will listen at address `http://localhost:1234` so please change your schemas (`id` and `$ref` properties)
31+
to fetch the remote schemas relative from this address
32+
33+
You can find a good example for all of these in the `tests/src/test/resources/org/everit/json/schema/issues/issue17` testcase.
34+
35+
If you successfully created your testcase, then it will fail with an `AssertionError` with a message like
36+
"validation failed with: org.everit.json.schema.ValidationException:..." or "did not throw ValidationException for invalid subject",
37+
and then you are ready to send a pull request.
838

939

1040
Building the project locally
@@ -18,3 +48,5 @@ Prerequisities: the following tools have to be installed:
1848
Steps for building the project:
1949
* clone the repository: `git clone https://github.com/everit-org/json-schema.git && cd json-schema/`
2050
* build it with maven: `mvn clean install`
51+
52+
(or just `mvn clean test` if you are only interested in running the tests)

0 commit comments

Comments
 (0)