Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

# 46 - Introduce Before|After All and Before|AfterEachTest logic #47

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Prepare testing environment:

Run integration test from path `{project-root}/testApi/target/scala-2.13`
```
scala testApi-assembly-0.1.0-SNAPSHOT.jar --env ./../../src/test/resources/test_project/localhost.env.json --test-root-path ./../../src/test/resources/test_project/
java -jar testApi-assembly-0.1.0-SNAPSHOT.jar --env ./../../src/test/resources/test_project/localhost.env.json --test-root-path ./../../src/test/resources/test_project/
```

Check report printed into console. All tests should be passed.
Expand All @@ -65,7 +65,7 @@ Jar files should be available on path `{project-root}/testApi/target/scala-2.13`
## How to run tests from jar file
Expect that you are in folder with test json files.
```
scala <path-to-assembly-jar>/testApi-assembly-0.1.0-SNAPSHOT.jar --env pc_1.json --test-root-path "."
java -jar <path-to-assembly-jar>/testApi-assembly-0.1.0-SNAPSHOT.jar --env pc_1.json --test-root-path "."
```
```
scala testapi_2.13-assembly.jar --help ─╯
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"$schema": "http://json-schema.org/draft-06/schema#",
"$ref": "#/definitions/suiteAfter",
"$ref": "#/definitions/afterAll",

"definitions": {
"suiteAfter": {
"afterAll": {
"type": "object",
"additionalProperties": true,
"properties": {
Expand All @@ -23,8 +23,8 @@
"name",
"methods"
],
"title": "SuiteAfter",
"description": "Defines a suite with its associated methods to be executed after the main tests."
"title": "AfterAll",
"description": "Defines a set of methods to be executed after all connected suites."
},
"Method": {
"type": "object",
Expand Down
160 changes: 160 additions & 0 deletions testApi/src/main/resources/schema/afterSuite.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"$schema": "http://json-schema.org/draft-06/schema#",
"$ref": "#/definitions/afterSuite",

"definitions": {
"afterSuite": {
"type": "object",
"additionalProperties": true,
"properties": {
"name": {
"type": "string",
"description": "The name of the suite."
},
"methods": {
"type": "array",
"items": {
"$ref": "#/definitions/Method"
},
"description": "An array of method objects associated with the suite."
}
},
"required": [
"name",
"methods"
],
"title": "AfterSuite",
"description": "Defines a set of methods to be executed after the connected Suite."
},
"Method": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "The name of the method."
},
"headers": {
"type": "array",
"items": {
"$ref": "#/definitions/Header"
},
"description": "Headers to be sent with the method request."
},
"action": {
"$ref": "#/definitions/Action",
"description": "Actions to be performed during the method execution."
},
"responseActions": {
"type": "array",
"items": {
"$ref": "#/definitions/ResponseAction"
},
"description": "Actions to be performed on the response of the method."
}
},
"required": [
"name",
"headers",
"action",
"responseActions"
],
"title": "Method",
"description": "Defines a single method within a suite."
},
"Header": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"enum": ["content-type", "authorization"],
"description": "The name of the header. Restricted to specific values."
},
"value": {
"type": "string",
"description": "The value of the header."
}
},
"required": [
"name",
"value"
],
"title": "Header",
"description": "Defines a header to be sent with a method request."
},
"Action": {
"type": "object",
"additionalProperties": false,
"properties": {
"method": {
"type": "string",
"enum": ["get", "post", "put", "delete"],
"description": "The HTTP method name for the action. Restricted to specific values."
},
"url": {
"type": "string",
"description": "The URL for the action."
},
"body": {
"type": ["string", "null"],
"description": "The body content for the action."
},
"params": {
"type": ["array", "null"],
"items": {
"$ref": "#/definitions/Param"
},
"description": "Parameters for the action."
}
},
"required": [
"method",
"url"
],
"title": "Action",
"description": "Defines an action to be performed during a method."
},
"ResponseAction": {
"type": "object",
"additionalProperties": false,
"properties": {
"method": {
"type": "string",
"enum": ["assert.response-time-is-below", "assert.response-time-is-above", "assert.status-code-equals", "assert.status-code-is-success", "assert.status-code-is-client-error", "assert.status-code-is-server-error", "assert.header-exists", "assert.header-value-equals", "assert.content-type-is-json", "assert.content-type-is-xml", "assert.content-type-is-html", "assert.cookie-exists", "assert.cookie-value-equals", "assert.cookie-is-secured", "assert.cookie-is-not-secured", "assert.body-equals", "assert.body-contains-text", "assert.body-is-empty", "assert.body-is-not-empty", "assert.body-length-equals", "assert.body-starts-with", "assert.body-ends-with", "assert.body-matches-regex", "assert.body-json-is-json-array", "assert.body-json-is-json-object", "assert.body-json-path-exists", "log.error", "log.warn", "log.info", "log.debug", "log.log-info-response", "extractJson.string-from-list", "extractJson.string-from-json-path"],
"description": "The method to be used for the response action. Restricted to specific values."
}
},
"patternProperties": {
"^[a-zA-Z_][a-zA-Z0-9_]*$": {
"type": "string"
}
},
"required": [
"method"
],
"title": "ResponseAction",
"description": "Defines an action to be performed on the response of a method."
},
"Param": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "The name of the parameter."
},
"value": {
"type": "string",
"description": "The value of the parameter."
}
},
"required": [
"name",
"value"
],
"title": "Param",
"description": "Defines a parameter for an action."
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"$schema": "http://json-schema.org/draft-06/schema#",
"$ref": "#/definitions/suiteBefore",
"$ref": "#/definitions/beforeAll",

"definitions": {
"suiteBefore": {
"beforeAll": {
"type": "object",
"additionalProperties": true,
"properties": {
Expand All @@ -23,8 +23,8 @@
"name",
"methods"
],
"title": "SuiteBefore",
"description": "Defines a suite with its associated methods."
"title": "BeforeAll",
"description": "Defines a set of methods to be executed before all suites."
},
"Method": {
"type": "object",
Expand Down
158 changes: 158 additions & 0 deletions testApi/src/main/resources/schema/beforeSuite.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
"$schema": "http://json-schema.org/draft-06/schema#",
"$ref": "#/definitions/beforeSuite",

"definitions": {
"beforeSuite": {
"type": "object",
"additionalProperties": true,
"properties": {
"name": {
"type": "string",
"description": "The name of the suite."
},
"methods": {
"type": "array",
"items": {
"$ref": "#/definitions/Method"
},
"description": "An array of method objects associated with the suite."
}
},
"required": [
"name",
"methods"
],
"title": "BeforeSuite",
"description": "Defines a set of methods to be executed before the connected Suite."
},
"Method": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "The name of the method."
},
"headers": {
"type": "array",
"items": {
"$ref": "#/definitions/Header"
},
"description": "Headers to be sent with the method request."
},
"action": {
"$ref": "#/definitions/Action",
"description": "Actions to be performed during the method execution."
},
"responseActions": {
"type": "array",
"items": {
"$ref": "#/definitions/ResponseAction"
},
"description": "Actions to be performed on the response of the method."
}
},
"required": [
"name",
"headers",
"action",
"responseActions"
],
"title": "Method",
"description": "Defines a single method within a suite."
},
"Header": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "The name of the header."
},
"value": {
"type": "string",
"description": "The value of the header."
}
},
"required": [
"name",
"value"
],
"title": "Header",
"description": "Defines a header to be sent with a method request."
},
"Action": {
"type": "object",
"additionalProperties": false,
"properties": {
"method": {
"type": "string",
"description": "The HTTP method name for the action."
},
"url": {
"type": "string",
"description": "The URL for the action."
},
"body": {
"type": ["string", "null"],
"description": "The body content for the action."
},
"params": {
"type": ["array", "null"],
"items": {
"$ref": "#/definitions/Param"
},
"description": "Parameters for the action."
}
},
"required": [
"method",
"url"
],
"title": "Action",
"description": "Defines an action to be performed during a method."
},
"ResponseAction": {
"type": "object",
"additionalProperties": false,
"properties": {
"method": {
"type": "string",
"enum": ["assert.response-time-is-below", "assert.response-time-is-above", "assert.status-code-equals", "assert.status-code-is-success", "assert.status-code-is-client-error", "assert.status-code-is-server-error", "assert.header-exists", "assert.header-value-equals", "assert.content-type-is-json", "assert.content-type-is-xml", "assert.content-type-is-html", "assert.cookie-exists", "assert.cookie-value-equals", "assert.cookie-is-secured", "assert.cookie-is-not-secured", "assert.body-equals", "assert.body-contains-text", "assert.body-is-empty", "assert.body-is-not-empty", "assert.body-length-equals", "assert.body-starts-with", "assert.body-ends-with", "assert.body-matches-regex", "assert.body-json-is-json-array", "assert.body-json-is-json-object", "assert.body-json-path-exists", "log.error", "log.warn", "log.info", "log.debug", "log.log-info-response", "extractJson.string-from-list", "extractJson.string-from-json-path"],
"description": "The method to be used for the response action."
}
},
"patternProperties": {
"^[a-zA-Z_][a-zA-Z0-9_]*$": {
"type": "string"
}
},
"required": [
"method"
],
"title": "ResponseAction",
"description": "Defines an action to be performed on the response of a method."
},
"Param": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "The name of the parameter."
},
"value": {
"type": "string",
"description": "The value of the parameter."
}
},
"required": [
"name",
"value"
],
"title": "Param",
"description": "Defines a parameter for an action."
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ case class ProjectLoadFailedException() extends Exception("Problems during proje
case class SuiteLoadFailedException(detail: String)
extends Exception(s"Problems during project loading. Details: $detail")

case class SuiteBeforeFailedException(detail: String)
case class BeforeSuiteFailedException(detail: String)
extends Exception(s"Problems during running before suite logic. Details: $detail")

case class UndefinedHeaderTypeException(undefinedType: String)
Expand Down
Loading
Loading