mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 22:04:56 +00:00
- Introduced `edge-cases.params.json` to define parameter sets for various edge case scenarios including null handling, boundary values, empty collections, special characters, numeric overflow, concurrent access, and malformed data. - Created `edge-cases.test.json` to implement parameterized tests for the defined edge cases, ensuring robust validation of edge case handling in the application. - Added `test-parameters_schema.json` to establish a schema for defining parameterized test input parameters, enhancing validation and structure. - Developed `tests_schema.json` to define the structure for parameterized unit tests, including setup, teardown, and test case definitions.
474 lines
12 KiB
JSON
474 lines
12 KiB
JSON
{
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
"$id": "https://metabuilder.dev/schemas/tests.schema.json",
|
|
"title": "Tests Schema",
|
|
"description": "Schema for defining parameterized unit tests",
|
|
"type": "object",
|
|
"required": ["schemaVersion", "package"],
|
|
"properties": {
|
|
"$schema": {
|
|
"type": "string",
|
|
"description": "JSON Schema reference"
|
|
},
|
|
"schemaVersion": {
|
|
"type": "string",
|
|
"description": "Schema version",
|
|
"pattern": "^\\d+\\.\\d+\\.\\d+$",
|
|
"default": "2.0.0"
|
|
},
|
|
"package": {
|
|
"type": "string",
|
|
"description": "Package identifier"
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "Test suite description"
|
|
},
|
|
"imports": {
|
|
"type": "array",
|
|
"description": "Imported test utilities and dependencies",
|
|
"items": {
|
|
"$ref": "#/definitions/import"
|
|
}
|
|
},
|
|
"setup": {
|
|
"type": "object",
|
|
"description": "Global test setup configuration",
|
|
"properties": {
|
|
"beforeAll": {
|
|
"type": "array",
|
|
"description": "Setup steps to run before all tests",
|
|
"items": {
|
|
"$ref": "#/definitions/setupStep"
|
|
}
|
|
},
|
|
"beforeEach": {
|
|
"type": "array",
|
|
"description": "Setup steps to run before each test",
|
|
"items": {
|
|
"$ref": "#/definitions/setupStep"
|
|
}
|
|
},
|
|
"afterEach": {
|
|
"type": "array",
|
|
"description": "Cleanup steps to run after each test",
|
|
"items": {
|
|
"$ref": "#/definitions/setupStep"
|
|
}
|
|
},
|
|
"afterAll": {
|
|
"type": "array",
|
|
"description": "Cleanup steps to run after all tests",
|
|
"items": {
|
|
"$ref": "#/definitions/setupStep"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"testSuites": {
|
|
"type": "array",
|
|
"description": "Test suite definitions",
|
|
"items": {
|
|
"$ref": "#/definitions/testSuite"
|
|
}
|
|
}
|
|
},
|
|
"definitions": {
|
|
"import": {
|
|
"type": "object",
|
|
"required": ["from", "import"],
|
|
"properties": {
|
|
"from": {
|
|
"type": "string",
|
|
"description": "Module to import from"
|
|
},
|
|
"import": {
|
|
"type": "array",
|
|
"description": "Items to import",
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"setupStep": {
|
|
"type": "object",
|
|
"required": ["type"],
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"description": "Setup step type",
|
|
"enum": [
|
|
"initialize",
|
|
"mock",
|
|
"fixture",
|
|
"database",
|
|
"cleanup",
|
|
"custom"
|
|
]
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"description": "Step name"
|
|
},
|
|
"config": {
|
|
"type": "object",
|
|
"description": "Step-specific configuration",
|
|
"additionalProperties": true
|
|
}
|
|
}
|
|
},
|
|
"testSuite": {
|
|
"type": "object",
|
|
"required": ["id", "name", "tests"],
|
|
"properties": {
|
|
"id": {
|
|
"type": "string",
|
|
"description": "Unique test suite identifier"
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"description": "Test suite name"
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "Test suite description"
|
|
},
|
|
"skip": {
|
|
"type": "boolean",
|
|
"description": "Whether to skip this test suite",
|
|
"default": false
|
|
},
|
|
"only": {
|
|
"type": "boolean",
|
|
"description": "Run only this test suite",
|
|
"default": false
|
|
},
|
|
"tags": {
|
|
"type": "array",
|
|
"description": "Tags for filtering tests",
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"timeout": {
|
|
"type": "integer",
|
|
"description": "Timeout in milliseconds for tests in this suite",
|
|
"minimum": 0
|
|
},
|
|
"setup": {
|
|
"type": "object",
|
|
"description": "Suite-specific setup",
|
|
"properties": {
|
|
"beforeAll": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/setupStep"
|
|
}
|
|
},
|
|
"beforeEach": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/setupStep"
|
|
}
|
|
},
|
|
"afterEach": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/setupStep"
|
|
}
|
|
},
|
|
"afterAll": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/setupStep"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tests": {
|
|
"type": "array",
|
|
"description": "Test case definitions",
|
|
"items": {
|
|
"$ref": "#/definitions/test"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"test": {
|
|
"type": "object",
|
|
"required": ["id", "name"],
|
|
"properties": {
|
|
"id": {
|
|
"type": "string",
|
|
"description": "Unique test identifier"
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"description": "Test name/description"
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "Detailed test description"
|
|
},
|
|
"skip": {
|
|
"type": "boolean",
|
|
"description": "Whether to skip this test",
|
|
"default": false
|
|
},
|
|
"only": {
|
|
"type": "boolean",
|
|
"description": "Run only this test",
|
|
"default": false
|
|
},
|
|
"tags": {
|
|
"type": "array",
|
|
"description": "Test tags",
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"timeout": {
|
|
"type": "integer",
|
|
"description": "Test timeout in milliseconds",
|
|
"minimum": 0
|
|
},
|
|
"retry": {
|
|
"type": "integer",
|
|
"description": "Number of retry attempts for flaky tests",
|
|
"minimum": 0,
|
|
"maximum": 5,
|
|
"default": 0
|
|
},
|
|
"parameterized": {
|
|
"type": "boolean",
|
|
"description": "Whether this is a parameterized test",
|
|
"default": false
|
|
},
|
|
"parameters": {
|
|
"oneOf": [
|
|
{
|
|
"type": "string",
|
|
"description": "Reference to parameter set ID from test-parameters schema"
|
|
},
|
|
{
|
|
"type": "array",
|
|
"description": "Inline parameter definitions",
|
|
"items": {
|
|
"$ref": "#/definitions/parameterCase"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"arrange": {
|
|
"type": "object",
|
|
"description": "Test arrange phase (setup)",
|
|
"properties": {
|
|
"given": {
|
|
"type": "string",
|
|
"description": "Given condition description (BDD style)"
|
|
},
|
|
"setup": {
|
|
"type": "array",
|
|
"description": "Setup steps",
|
|
"items": {
|
|
"$ref": "#/definitions/setupStep"
|
|
}
|
|
},
|
|
"mocks": {
|
|
"type": "array",
|
|
"description": "Mock definitions",
|
|
"items": {
|
|
"$ref": "#/definitions/mock"
|
|
}
|
|
},
|
|
"fixtures": {
|
|
"type": "object",
|
|
"description": "Test fixtures",
|
|
"additionalProperties": true
|
|
}
|
|
}
|
|
},
|
|
"act": {
|
|
"type": "object",
|
|
"description": "Test act phase (execution)",
|
|
"required": ["type"],
|
|
"properties": {
|
|
"when": {
|
|
"type": "string",
|
|
"description": "When action description (BDD style)"
|
|
},
|
|
"type": {
|
|
"type": "string",
|
|
"description": "Action type",
|
|
"enum": [
|
|
"function_call",
|
|
"api_request",
|
|
"event_trigger",
|
|
"custom"
|
|
]
|
|
},
|
|
"target": {
|
|
"type": "string",
|
|
"description": "Function/endpoint/event to test"
|
|
},
|
|
"input": {
|
|
"description": "Input data/parameters"
|
|
},
|
|
"config": {
|
|
"type": "object",
|
|
"description": "Action-specific configuration",
|
|
"additionalProperties": true
|
|
}
|
|
}
|
|
},
|
|
"assert": {
|
|
"type": "object",
|
|
"description": "Test assert phase (verification)",
|
|
"properties": {
|
|
"then": {
|
|
"type": "string",
|
|
"description": "Then expectation description (BDD style)"
|
|
},
|
|
"expectations": {
|
|
"type": "array",
|
|
"description": "Assertion expectations",
|
|
"items": {
|
|
"$ref": "#/definitions/assertion"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"parameterCase": {
|
|
"type": "object",
|
|
"required": ["case", "input"],
|
|
"properties": {
|
|
"case": {
|
|
"type": "string",
|
|
"description": "Test case name/description"
|
|
},
|
|
"input": {
|
|
"description": "Input parameters for this case"
|
|
},
|
|
"expected": {
|
|
"description": "Expected output/result"
|
|
},
|
|
"shouldThrow": {
|
|
"type": "boolean",
|
|
"description": "Whether this case should throw an error",
|
|
"default": false
|
|
},
|
|
"expectedError": {
|
|
"type": "string",
|
|
"description": "Expected error message or pattern"
|
|
},
|
|
"skip": {
|
|
"type": "boolean",
|
|
"description": "Skip this parameter case",
|
|
"default": false
|
|
},
|
|
"only": {
|
|
"type": "boolean",
|
|
"description": "Run only this parameter case",
|
|
"default": false
|
|
}
|
|
}
|
|
},
|
|
"mock": {
|
|
"type": "object",
|
|
"required": ["target", "behavior"],
|
|
"properties": {
|
|
"target": {
|
|
"type": "string",
|
|
"description": "Function/module to mock"
|
|
},
|
|
"type": {
|
|
"type": "string",
|
|
"description": "Mock type",
|
|
"enum": ["function", "module", "class", "object"],
|
|
"default": "function"
|
|
},
|
|
"behavior": {
|
|
"type": "object",
|
|
"description": "Mock behavior configuration",
|
|
"properties": {
|
|
"returnValue": {
|
|
"description": "Value to return"
|
|
},
|
|
"throwError": {
|
|
"type": "string",
|
|
"description": "Error to throw"
|
|
},
|
|
"implementation": {
|
|
"type": "string",
|
|
"description": "Custom implementation reference"
|
|
},
|
|
"calls": {
|
|
"type": "array",
|
|
"description": "Sequential return values for multiple calls",
|
|
"items": {
|
|
"description": "Return value for each call"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"assertion": {
|
|
"type": "object",
|
|
"required": ["type"],
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"description": "Assertion type",
|
|
"enum": [
|
|
"equals",
|
|
"deepEquals",
|
|
"strictEquals",
|
|
"notEquals",
|
|
"greaterThan",
|
|
"lessThan",
|
|
"greaterThanOrEqual",
|
|
"lessThanOrEqual",
|
|
"contains",
|
|
"matches",
|
|
"throws",
|
|
"notThrows",
|
|
"truthy",
|
|
"falsy",
|
|
"null",
|
|
"notNull",
|
|
"undefined",
|
|
"notUndefined",
|
|
"instanceOf",
|
|
"hasProperty",
|
|
"hasLength",
|
|
"custom"
|
|
]
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "Assertion description"
|
|
},
|
|
"actual": {
|
|
"description": "Actual value or path to value (e.g., 'result.data.id')"
|
|
},
|
|
"expected": {
|
|
"description": "Expected value"
|
|
},
|
|
"message": {
|
|
"type": "string",
|
|
"description": "Custom assertion failure message"
|
|
},
|
|
"negate": {
|
|
"type": "boolean",
|
|
"description": "Negate the assertion",
|
|
"default": false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|