| 1 | { |
| 2 | "title": "PBT Observations", |
| 3 | "description": "PBT Observations define a standard way to communicate what happened when property-based tests were run. They describe test cases, or general notifications classified as info, alert, or error messages.", |
| 4 | "oneOf": [ |
| 5 | { |
| 6 | "description": "Describes the inputs to and result of running some test function on a particular input. The test might have passed, failed, or been abandoned part way through (e.g. because we failed a |.filter| condition).", |
| 7 | "type": "object", |
| 8 | "properties": { |
| 9 | "type": { |
| 10 | "const": "test_case", |
| 11 | "description": "A tag which labels this observation as data about a specific test case." |
| 12 | }, |
| 13 | "status": { |
| 14 | "enum": ["passed", "failed", "gave_up"], |
| 15 | "description": "Whether the test passed, failed, or was aborted before completion (e.g. due to use of |.filter|). Note that if we gave_up partway, values such as arguments and features may be incomplete." |
| 16 | }, |
| 17 | "status_reason": { |
| 18 | "type": "string", |
| 19 | "description": "If non-empty, the reason for which the test failed or was abandoned. For Hypothesis, this is usually the exception type and location." |
| 20 | }, |
| 21 | "representation": { |
| 22 | "type": "string", |
| 23 | "description": "The string representation of the input. In Hypothesis, this includes the property name and arguments (like ``test_a(a=1)``), any interactive draws from |st.data|, and additionally some comments from |Phase.explain| for failing examples." |
| 24 | }, |
| 25 | "arguments": { |
| 26 | "type": "object", |
| 27 | "description": "A structured json-encoded representation of the input. Hypothesis provides a dictionary of argument names to json-ified values, including interactive draws from the |st.data| strategy. If 'status' is 'gave_up', this may be absent or incomplete. In other libraries this can be any object." |
| 28 | }, |
| 29 | "how_generated": { |
| 30 | "type": ["string", "null"], |
| 31 | "description": "How the input was generated, if known. In Hypothesis this might be an explicit example, generated during a particular phase with some backend, or by replaying the minimal failing example." |
| 32 | }, |
| 33 | "features": { |
| 34 | "type": "object", |
| 35 | "description": "Runtime observations which might help explain what this test case did. Hypothesis includes |target| scores, tags from |event|, and so on." |
| 36 | }, |
| 37 | "coverage": { |
| 38 | "type": ["object", "null"], |
| 39 | "description": "Mapping of filename to list of covered line numbers, if coverage information is available, or None if not. Hypothesis deliberately omits stdlib and site-packages code.", |
| 40 | "additionalProperties": { |
| 41 | "type": "array", |
| 42 | "items": {"type": "integer", "minimum": 1}, |
| 43 | "uniqueItems": true |
| 44 | } |
| 45 | }, |
| 46 | "timing": { |
| 47 | "type": "object", |
| 48 | "description": "The time in seconds taken by non-overlapping parts of this test case. Hypothesis reports ``execute:test``, ``overall:gc``, and ``generate:{argname}`` for each argument.", |
| 49 | "additionalProperties": { |
| 50 | "type": "number", |
| 51 | "minimum": 0 |
| 52 | } |
| 53 | }, |
| 54 | "metadata": { |
| 55 | "type": "object", |
| 56 | "description": "Arbitrary metadata which might be of interest, but does not semantically fit in 'features'. For example, Hypothesis includes the traceback for failing tests here." |
| 57 | }, |
| 58 | "property": { |
| 59 | "type": "string", |
| 60 | "description": "The name or representation of the test function we're running." |
| 61 | }, |
| 62 | "run_start": { |
| 63 | "type": "number", |
| 64 | "description": "unix timestamp at which we started running this test function, so that later analysis can group test cases by run." |
| 65 | } |
| 66 | }, |
| 67 | "required": ["type", "status", "status_reason", "representation", "arguments", "how_generated", "features", "coverage", "timing", "metadata", "property", "run_start"], |
| 68 | "additionalProperties": false |
| 69 | }, |
| 70 | { |
| 71 | "description": "Info, alert, and error messages correspond to a group of test cases or the overall run, and are intended for humans rather than machine analysis.", |
| 72 | "type": "object", |
| 73 | "properties": { |
| 74 | "type": { |
| 75 | "enum": ["info", "alert", "error"], |
| 76 | "description": "A tag which labels this observation as general information to show the user. Hypothesis uses info messages to report statistics; alert or error messages can be provided by plugins." |
| 77 | }, |
| 78 | "title": { |
| 79 | "type": "string", |
| 80 | "description": "The title of this message" |
| 81 | }, |
| 82 | "content": { |
| 83 | "type": ["string", "object"], |
| 84 | "description": "The body of the message. Strings are presumed to be human-readable messages in markdown format; dictionaries may contain arbitrary information (as for test-case metadata)." |
| 85 | }, |
| 86 | "property": { |
| 87 | "type": "string", |
| 88 | "description": "The name or representation of the test function we're running. For Hypothesis, usually the Pytest nodeid." |
| 89 | }, |
| 90 | "run_start": { |
| 91 | "type": "number", |
| 92 | "description": "unix timestamp at which we started running this test function, so that later analysis can group test cases by run." |
| 93 | } |
| 94 | }, |
| 95 | "required": ["type", "title", "content", "property", "run_start"], |
| 96 | "additionalProperties": false |
| 97 | } |
| 98 | ] |
| 99 | } |