Integration Test
Advanced Generation
Generation Examples
In this section, we will go over how to customize the Skyramp CLI test generation command to achieve specific use cases for your test execution.
Generation Examples
In this section, we will go over how to customize the Skyramp CLI test generation command to achieve specific use cases for your test execution.
Generation Examples
In this section, we will go over how to customize the Skyramp CLI test generation command to achieve specific use cases for your test execution.
Python
Java
TS / JS
Test Generation using OpenAPI Spec
1. Generate test from request data
When generating an integration test for a CRUD scenario via OpenAPI spec, you can also specify request data in combination with the API schema to override the request body from the schema for the POST request.
request.json
{
"category": "electronics",
"description": "speaker",
"image_url": "photo",
"in_stock": true,
"name": "boombox",
"price": 25
}
Generate Command
skyramp generate integration rest https://www.demoshop.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--request-data @request.json \
--api-schema
2. Specification of form parameters
The form-params flag allows you to override the POST request data of the integration test with your own form parameters.
skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--form-params category=electronics \
--form-params description=speaker \
--form-params image_url=photo \
--form-params in_stock=false \
--form-params name=boombox \
--form-params price=25 \
--api-schema
3. Change of authentication header
By default, Skyramp assumes a Bearer token. You can define the key of your authentication header with the auth-header flag.
skyramp generate integration rest https://www.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--auth-header X-API-KEY \
--api-schema
4. Specification of path and query parameters
If the --path-params
flag is specified, Skyramp will generate the integration test but ignore the flag. This is because integration tests use API call chaining to simulate the full CRUD lifecycle.
The query-params
flag is not supported.
Test Generation using Skyramp Trace
For these examples, please ensure you have the following sample trace file saved in your local directory.
Recap: Including / Excluding URLs from Trace
Skyramp provides special flags related to filtering certain URLs from traces to focus your integration test generation on the most critical flows.
URLs need to be specified either as an exact path to the endpoint or in combination with a wildcard. For example:
demoshop.skyramp.dev/products
will only filter for POST and GET of the products endpoint.demoshop.skyramp.dev/products*
will filter for all products endpoints + any nested endpoints.demoshop.skyramp.dev/products/*
will filter only for any nested endpoints that require a product ID. It will not generate requests for POST and GET products.
For endpoints that require path parameters, please replace the path parameter with the wildcard:
Convert
demoshop.skyramp.dev/products/{product_id}/reviews
todemoshop.skyramp.dev/products/*/reviews
.
5. Include certain URLs from the trace in the test
If you are only looking to test specific requests collected in your trace, you can filter for those URLs using the --include
flag.
skyramp generate integration rest \
--language python \
--framework pytest \
--trace trace.json \
--include
6. Exclude certain URLs from the trace in the test
If your trace collected requests that are irrelevant to your integration test, you can exclude those URLs using the --exclude
flag.
skyramp generate integration rest \
--language python \
--framework pytest \
--trace trace.json \
--exclude
7. Using OpenAPI spec flags during generation
The following flags, when used to generate integration tests with the Skyramp Trace flag --trace
, will be ignored:
--api-schema
--form-params
--request-data
--response-data
--path-params
--auth-header
Test generation commands using the --query-params
or --response-status-code
flag will fail.
Useful General Examples
The following flag usage patterns will work regardless of whether you are generating an integration test from OpenAPI spec or from Skyramp Trace.
8. Specify test name and directory
You can override the default test name and specify the directory to save the generated test.
skyramp generate integration rest https://www.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--api-schema https://demoshop.skyramp.dev/openapi.json \
--output integration_test_products.py \
--output-dir
9. Test generation for Robot framework
Skyramp also supports the Robot Framework in Python. This section shows you how to generate and execute tests using Robot.
Generate Command
skyramp generate integration rest https://www.skyramp.dev/api/v1/products \
--language python \
--framework robot \
--api-schema
This command creates two test files:
products_integration_test.py
products_integration_test.robot
Execute the integration test
Ensure that authentication is properly set up and run the test using the Robot Framework. You can reference the generated Python file either in an existing robot file of yours or leverage the simple wrapper file we generate.
# Install dependencies
pip3 install robotframework
# Execute test
The results will be printed following the typical stdout from Robot. You can find more information on the generated outputs in the Robot documentation.
10. Change the test execution runtime to Docker
Skyramp also offers seamless support for testing applications in Docker. This allows you to test your services without worrying about network configurations and port mapping while developing locally. By default, Skyramp provides a Docker network where the test can be executed.
In this example, we are using api-sample as the service alias for our application. When testing your service, replace it with the service name you want to test.
skyramp generate smoke rest http://api-sample:8000/api/v1/products \
-X POST \
--language python \
--framework pytest \
--runtime docker \
--api-schema
You can also specify your own Docker network as follows:
skyramp generate integration rest https://api-sample:8000/api/v1/products \
--language python \
--framework pytest \
--api-schema https://demoshop.skyramp.dev/openapi.json \
--runtime docker \
--docker-network api-insight_default \
--docker-skyramp-port 35142
11. Deploy the Skyramp Dashboard
Skyramp also offers a simple dashboard to collect and help you analyze your test results. The Skyramp Dashboard is a lightweight Docker image that will automatically be brought up when executing the test. Please specify the --deploy-dashboard flag in the generation command.
Post execution, the dashboard will be available under http://localhost:3000/tests.
skyramp generate integration rest https://www.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--api-schema https://demoshop.skyramp.dev/openapi.json \
--deploy-dashboard
Python
Java
TS / JS
Test Generation using OpenAPI Spec
1. Generate test from request data
When generating an integration test for a CRUD scenario via OpenAPI spec, you can also specify request data in combination with the API schema to override the request body from the schema for the POST request.
request.json
{
"category": "electronics",
"description": "speaker",
"image_url": "photo",
"in_stock": true,
"name": "boombox",
"price": 25
}
Generate Command
skyramp generate integration rest https://www.demoshop.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--request-data @request.json \
--api-schema
2. Specification of form parameters
The form-params flag allows you to override the POST request data of the integration test with your own form parameters.
skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--form-params category=electronics \
--form-params description=speaker \
--form-params image_url=photo \
--form-params in_stock=false \
--form-params name=boombox \
--form-params price=25 \
--api-schema
3. Change of authentication header
By default, Skyramp assumes a Bearer token. You can define the key of your authentication header with the auth-header flag.
skyramp generate integration rest https://www.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--auth-header X-API-KEY \
--api-schema
4. Specification of path and query parameters
If the --path-params
flag is specified, Skyramp will generate the integration test but ignore the flag. This is because integration tests use API call chaining to simulate the full CRUD lifecycle.
The query-params
flag is not supported.
Test Generation using Skyramp Trace
For these examples, please ensure you have the following sample trace file saved in your local directory.
Recap: Including / Excluding URLs from Trace
Skyramp provides special flags related to filtering certain URLs from traces to focus your integration test generation on the most critical flows.
URLs need to be specified either as an exact path to the endpoint or in combination with a wildcard. For example:
demoshop.skyramp.dev/products
will only filter for POST and GET of the products endpoint.demoshop.skyramp.dev/products*
will filter for all products endpoints + any nested endpoints.demoshop.skyramp.dev/products/*
will filter only for any nested endpoints that require a product ID. It will not generate requests for POST and GET products.
For endpoints that require path parameters, please replace the path parameter with the wildcard:
Convert
demoshop.skyramp.dev/products/{product_id}/reviews
todemoshop.skyramp.dev/products/*/reviews
.
5. Include certain URLs from the trace in the test
If you are only looking to test specific requests collected in your trace, you can filter for those URLs using the --include
flag.
skyramp generate integration rest \
--language python \
--framework pytest \
--trace trace.json \
--include
6. Exclude certain URLs from the trace in the test
If your trace collected requests that are irrelevant to your integration test, you can exclude those URLs using the --exclude
flag.
skyramp generate integration rest \
--language python \
--framework pytest \
--trace trace.json \
--exclude
7. Using OpenAPI spec flags during generation
The following flags, when used to generate integration tests with the Skyramp Trace flag --trace
, will be ignored:
--api-schema
--form-params
--request-data
--response-data
--path-params
--auth-header
Test generation commands using the --query-params
or --response-status-code
flag will fail.
Useful General Examples
The following flag usage patterns will work regardless of whether you are generating an integration test from OpenAPI spec or from Skyramp Trace.
8. Specify test name and directory
You can override the default test name and specify the directory to save the generated test.
skyramp generate integration rest https://www.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--api-schema https://demoshop.skyramp.dev/openapi.json \
--output integration_test_products.py \
--output-dir
9. Test generation for Robot framework
Skyramp also supports the Robot Framework in Python. This section shows you how to generate and execute tests using Robot.
Generate Command
skyramp generate integration rest https://www.skyramp.dev/api/v1/products \
--language python \
--framework robot \
--api-schema
This command creates two test files:
products_integration_test.py
products_integration_test.robot
Execute the integration test
Ensure that authentication is properly set up and run the test using the Robot Framework. You can reference the generated Python file either in an existing robot file of yours or leverage the simple wrapper file we generate.
# Install dependencies
pip3 install robotframework
# Execute test
The results will be printed following the typical stdout from Robot. You can find more information on the generated outputs in the Robot documentation.
10. Change the test execution runtime to Docker
Skyramp also offers seamless support for testing applications in Docker. This allows you to test your services without worrying about network configurations and port mapping while developing locally. By default, Skyramp provides a Docker network where the test can be executed.
In this example, we are using api-sample as the service alias for our application. When testing your service, replace it with the service name you want to test.
skyramp generate smoke rest http://api-sample:8000/api/v1/products \
-X POST \
--language python \
--framework pytest \
--runtime docker \
--api-schema
You can also specify your own Docker network as follows:
skyramp generate integration rest https://api-sample:8000/api/v1/products \
--language python \
--framework pytest \
--api-schema https://demoshop.skyramp.dev/openapi.json \
--runtime docker \
--docker-network api-insight_default \
--docker-skyramp-port 35142
11. Deploy the Skyramp Dashboard
Skyramp also offers a simple dashboard to collect and help you analyze your test results. The Skyramp Dashboard is a lightweight Docker image that will automatically be brought up when executing the test. Please specify the --deploy-dashboard flag in the generation command.
Post execution, the dashboard will be available under http://localhost:3000/tests.
skyramp generate integration rest https://www.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--api-schema https://demoshop.skyramp.dev/openapi.json \
--deploy-dashboard
Python
Java
TS / JS
Test Generation using OpenAPI Spec
1. Generate test from request data
When generating an integration test for a CRUD scenario via OpenAPI spec, you can also specify request data in combination with the API schema to override the request body from the schema for the POST request.
request.json
{
"category": "electronics",
"description": "speaker",
"image_url": "photo",
"in_stock": true,
"name": "boombox",
"price": 25
}
Generate Command
skyramp generate integration rest https://www.demoshop.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--request-data @request.json \
--api-schema
2. Specification of form parameters
The form-params flag allows you to override the POST request data of the integration test with your own form parameters.
skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--form-params category=electronics \
--form-params description=speaker \
--form-params image_url=photo \
--form-params in_stock=false \
--form-params name=boombox \
--form-params price=25 \
--api-schema
3. Change of authentication header
By default, Skyramp assumes a Bearer token. You can define the key of your authentication header with the auth-header flag.
skyramp generate integration rest https://www.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--auth-header X-API-KEY \
--api-schema
4. Specification of path and query parameters
If the --path-params
flag is specified, Skyramp will generate the integration test but ignore the flag. This is because integration tests use API call chaining to simulate the full CRUD lifecycle.
The query-params
flag is not supported.
Test Generation using Skyramp Trace
For these examples, please ensure you have the following sample trace file saved in your local directory.
Recap: Including / Excluding URLs from Trace
Skyramp provides special flags related to filtering certain URLs from traces to focus your integration test generation on the most critical flows.
URLs need to be specified either as an exact path to the endpoint or in combination with a wildcard. For example:
demoshop.skyramp.dev/products
will only filter for POST and GET of the products endpoint.demoshop.skyramp.dev/products*
will filter for all products endpoints + any nested endpoints.demoshop.skyramp.dev/products/*
will filter only for any nested endpoints that require a product ID. It will not generate requests for POST and GET products.
For endpoints that require path parameters, please replace the path parameter with the wildcard:
Convert
demoshop.skyramp.dev/products/{product_id}/reviews
todemoshop.skyramp.dev/products/*/reviews
.
5. Include certain URLs from the trace in the test
If you are only looking to test specific requests collected in your trace, you can filter for those URLs using the --include
flag.
skyramp generate integration rest \
--language python \
--framework pytest \
--trace trace.json \
--include
6. Exclude certain URLs from the trace in the test
If your trace collected requests that are irrelevant to your integration test, you can exclude those URLs using the --exclude
flag.
skyramp generate integration rest \
--language python \
--framework pytest \
--trace trace.json \
--exclude
7. Using OpenAPI spec flags during generation
The following flags, when used to generate integration tests with the Skyramp Trace flag --trace
, will be ignored:
--api-schema
--form-params
--request-data
--response-data
--path-params
--auth-header
Test generation commands using the --query-params
or --response-status-code
flag will fail.
Useful General Examples
The following flag usage patterns will work regardless of whether you are generating an integration test from OpenAPI spec or from Skyramp Trace.
8. Specify test name and directory
You can override the default test name and specify the directory to save the generated test.
skyramp generate integration rest https://www.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--api-schema https://demoshop.skyramp.dev/openapi.json \
--output integration_test_products.py \
--output-dir
9. Test generation for Robot framework
Skyramp also supports the Robot Framework in Python. This section shows you how to generate and execute tests using Robot.
Generate Command
skyramp generate integration rest https://www.skyramp.dev/api/v1/products \
--language python \
--framework robot \
--api-schema
This command creates two test files:
products_integration_test.py
products_integration_test.robot
Execute the integration test
Ensure that authentication is properly set up and run the test using the Robot Framework. You can reference the generated Python file either in an existing robot file of yours or leverage the simple wrapper file we generate.
# Install dependencies
pip3 install robotframework
# Execute test
The results will be printed following the typical stdout from Robot. You can find more information on the generated outputs in the Robot documentation.
10. Change the test execution runtime to Docker
Skyramp also offers seamless support for testing applications in Docker. This allows you to test your services without worrying about network configurations and port mapping while developing locally. By default, Skyramp provides a Docker network where the test can be executed.
In this example, we are using api-sample as the service alias for our application. When testing your service, replace it with the service name you want to test.
skyramp generate smoke rest http://api-sample:8000/api/v1/products \
-X POST \
--language python \
--framework pytest \
--runtime docker \
--api-schema
You can also specify your own Docker network as follows:
skyramp generate integration rest https://api-sample:8000/api/v1/products \
--language python \
--framework pytest \
--api-schema https://demoshop.skyramp.dev/openapi.json \
--runtime docker \
--docker-network api-insight_default \
--docker-skyramp-port 35142
11. Deploy the Skyramp Dashboard
Skyramp also offers a simple dashboard to collect and help you analyze your test results. The Skyramp Dashboard is a lightweight Docker image that will automatically be brought up when executing the test. Please specify the --deploy-dashboard flag in the generation command.
Post execution, the dashboard will be available under http://localhost:3000/tests.
skyramp generate integration rest https://www.skyramp.dev/api/v1/products \
--language python \
--framework pytest \
--api-schema https://demoshop.skyramp.dev/openapi.json \
--deploy-dashboard