Skip to content

Commit

Permalink
schema: Update to allow sequences of inputs/expect
Browse files Browse the repository at this point in the history
References #9
  • Loading branch information
jonnor committed Apr 20, 2016
1 parent 499bb75 commit 7dc18e7
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 24 deletions.
66 changes: 66 additions & 0 deletions examples/sequences.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: "Sequence of inputs/expect, for testing stateful component"
topic: "DummyComponent"
cases:
-
name: 'correct data using spacy notation'
assertion: 'should pass'
inputs: # NOTE: should only sequence for stateful components. Normally use multiple testcases instead
-
in: true
-
in: false
expect:
-
out:
equals: true
-
out:
equals: false
-
name: 'correct data using compact notation'
assertion: 'should pass'
inputs:
- { in: 1000 }
- { in: 1001 }
expect:
- { out: { equals: 1000 } }
- { out: { equals: 1001 } }


# Failing cases
-
name: 'mismatch between number of inputs and expect'
assertion: 'should fail'
inputs:
- { in: 1000 }
expect:
- { out: { equals: 1000 } }
- { out: { equals: 1001 } }
-
name: 'first output in sequence wrong'
assertion: 'should fail'
inputs:
- { in: 1000 }
- { in: 1001 }
expect:
- { out: { equals: 42 } }
- { out: { equals: 1001 } }
-
name: 'second output in sequence wrong'
assertion: 'should fail'
inputs:
- { in: 1000 }
- { in: 1001 }
expect:
- { out: { equals: 1000 } }
- { out: { equals: 42 } }
-
name: 'all outputs in sequence wrong'
assertion: 'should fail'
inputs:
- { in: 0 }
- { in: 1 }
expect:
- { out: { equals: 2 } }
- { out: { equals: 3 } }

18 changes: 18 additions & 0 deletions schema/outputdata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"id": "outputdata.json",
"$schema": "http://json-schema.org/draft-04/schema",
"title": "Output data",
"description": "Data expected in a testcase.\nEach key refers to a port, and the value is a description of the expected message on that port.\nThere can be one expectation (check) on each message, or an array of them.\n",
"type": "object",
"items": {
"oneOf": [
{
"$ref": "expectation.json"
},
{
"$ref": "expectations.json"
}
]
},
"required": []
}
40 changes: 26 additions & 14 deletions schema/testcase.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,34 @@
"description": "Description of what this testcase asserts"
},
"inputs": {
"type": "object",
"description": "The inputs send to the fixture input ports"
"description": "The inputs send to the fixture input ports, or a sequence of such inputs",
"oneOf": [
{
"type": "object"
},
{
"type": "array",
"items": {
"type": "object"
}
}
]
},
"expect": {
"type": "object",
"items": {
"oneOf": [
{
"$ref": "expectation.json"
},
{
"$ref": "expectations.json"
}
]
},
"description": "Expected data on fixture output ports.\nOne message is expected per mentioned port.\n"
"description": "Expected data on fixture output ports.\nCan either be an object, or a sequence of such objects.\n",
"oneOf": [
{
"$ref": "outputdata.json"
},
{
"type": "array",
"items": [
{
"$ref": "outputdata.json"
}
]
}
]
},
"timeout": {
"type": "number",
Expand Down
14 changes: 14 additions & 0 deletions schemata/outputdata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
id: outputdata.json
"$schema": "http://json-schema.org/draft-04/schema"
title: Output data
description: |
Data expected in a testcase.
Each key refers to a port, and the value is a description of the expected message on that port.
There can be one expectation (check) on each message, or an array of them.
type: object
items:
oneOf:
- "$ref": "expectation.json"
- "$ref": "expectations.json"
required: []
30 changes: 20 additions & 10 deletions schemata/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,34 @@ title: Testcase
description: "A single test case"
type: object
properties:
# mandatory
name:
type: string
description: 'Name of this testcase/scenario'
assertion:
type: string
description: 'Description of what this testcase asserts'
inputs: # TODO: allow a list
type: object
description: 'The inputs send to the fixture input ports'
expect: # TODO: allow a list
type: object
items:
oneOf:
- "$ref": "expectation.json"
- "$ref": "expectations.json"
inputs:
description: 'The inputs send to the fixture input ports, or a sequence of such inputs'
oneOf:
- # inputsdata
type: object
- # sequence of inputsdata
type: array
items:
type: object
expect:
description: |
Expected data on fixture output ports.
One message is expected per mentioned port.
Can either be an object, or a sequence of such objects.
oneOf:
- "$ref": "outputdata.json"
- # sequence of expectdata
type: array
items:
- "$ref": "outputdata.json"

# optional
timeout:
type: number
description: 'Timeout (in milliseconds). Overrides that set in the suite'
Expand Down

0 comments on commit 7dc18e7

Please sign in to comment.