The crate provides a procedural macro attribute that allow to generate all the test cases described by JSON-Schema-Test-Suite.
The main objective is to ensure that for each test a mock server is started and will be able to
capture all the requests, ensuring that tests can be ran only interacting with cargo test
In order to ude the procedural macro attribute there are few assumptions that are made:
lazy_static
dependency is added into your [dev-dependencies]
section of the Cargo.toml
filemockito
dependency is added into your [dev-dependencies]
section of the Cargo.toml
fileserde-json
dependency is added into your [dev-dependencies]
section of the Cargo.toml
filefn (&str, json_schema_test_suite::TestCase) -> ()
```toml
[dev-dependencies] jsonschematest_suite = "0"
*
version is never recommended).lazystatic = "*" mockito = "*" serdejson = "*" ```
```rust use jsonschematestsuite::{jsonschematestsuite, TestCase};
// If no tests should be ignored
// path separator is assumed to be `/` (regardless of the run platform)
"path/to/JSON-Schema-Test-Suite/repository",
// test directory (in <JSON-Schema-Test-Suite>/tests/<test_directory>)
"draft7"
)]
// If some tests needs to be ignored, just defined them into { ... }
as follow
// path separator is assumed to be `/` (regardless of the run platform)
"path/to/JSON-Schema-Test-Suite/repository",
// test directory (in <JSON-Schema-Test-Suite>/tests/<test_directory>)
"draft6",
{ // Names, as generated by the macro, of the tests to ignore
// NOTE: They can be regular expression as well.
"name of the tests to ignore",
}
)]
fn mysimpletest(
// address of the HTTP server providing the remote files of JSON-Schema-Test-Suite.
// The format will be: hostname:port
.
// This parameter is passed because by starting a mock server we might not start it
// into localhost:1234
as expected by JSON-Schema-Test-Suite
serveraddress: &str,
// Representation of the test case
testcase: TestCase,
) {
// TODO: Add here your testing logic
}
```
License: MIT