Generation

Getting Started

Getting Started

Smoke Test

Integration Testing

This guide describes generating integration tests using the Skyramp CLI. Throughout this guide, we are using Skyramp’s Demo Shop API as an example REST API. You can find all relevant information on the Demo Shop here.

If you haven’t already installed Skyramp, follow the instructions here.

1. Overview

Integration testing verifies that different components of a system work together as expected. It catches issues arising from interactions between modules, APIs, or external systems that unit tests might miss. By validating data flow, dependencies, and system behavior, integration testing ensures software functions reliably in real-world environments.

2. Generate Integration Test for REST APIs

This section explains how you can use Skyramp to generate integration tests for REST APIs in Python. You can generate integration tests for:

  • all methods of an endpoint.

To reliably generate test cases, we require at least one of the following inputs:

  • OpenAPI schema (required if generating for all methods of an endpoint)

    • Can be provided as JSON or YAML file

Integration Testing

This guide describes generating integration tests using the Skyramp CLI. Throughout this guide, we are using Skyramp’s Demo Shop API as an example REST API. You can find all relevant information on the Demo Shop here.

If you haven’t already installed Skyramp, follow the instructions here.

1. Overview

Integration testing verifies that different components of a system work together as expected. It catches issues arising from interactions between modules, APIs, or external systems that unit tests might miss. By validating data flow, dependencies, and system behavior, integration testing ensures software functions reliably in real-world environments.

2. Generate Integration Test for REST APIs

This section explains how you can use Skyramp to generate integration tests for REST APIs in Python. You can generate integration tests for:

  • all methods of an endpoint.

To reliably generate test cases, we require at least one of the following inputs:

  • OpenAPI schema (required if generating for all methods of an endpoint)

    • Can be provided as JSON or YAML file

Integration Testing

This guide describes generating integration tests using the Skyramp CLI. Throughout this guide, we are using Skyramp’s Demo Shop API as an example REST API. You can find all relevant information on the Demo Shop here.

If you haven’t already installed Skyramp, follow the instructions here.

1. Overview

Integration testing verifies that different components of a system work together as expected. It catches issues arising from interactions between modules, APIs, or external systems that unit tests might miss. By validating data flow, dependencies, and system behavior, integration testing ensures software functions reliably in real-world environments.

2. Generate Integration Test for REST APIs

This section explains how you can use Skyramp to generate integration tests for REST APIs in Python. You can generate integration tests for:

  • all methods of an endpoint.

To reliably generate test cases, we require at least one of the following inputs:

  • OpenAPI schema (required if generating for all methods of an endpoint)

    • Can be provided as JSON or YAML file

Python

2.1 Generate Command

Skyramp generates test cases for all methods for the specified path/url and its direct children. For cases, where the direct parent path/url has relevant methods, Skyramp will also generate test cases.

We are using https://demoshop.skyramp.dev/api/v1/products as a placeholder here for your <url-to-endpoint>.

skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
--language python \
--framework robot \
--api-schema openapi.json

This command generates two files:

  • products_POST_integration_test.py

  • products_POST_integration_test.robot (simple Robot wrapper file)

The content of the generated test is explained in Section 4 below.

Adjustments

Below are a few flags to customize the test generation. Additional flags are explained here.

  • --runtime: Allows you to specify the environment in which you want the test to run [docker, k8s, local]

  • --auth-header: This flag allows you to specify the key of your authentication header, e.g. --auth-header X-API-KEY. By default, we assume Bearer.

  • --path-params: This flag allows you to override path parameters from your endpoint URL or the pre-defined values in the API schema, e.g. --path-params id=3fa85f64-5717-4562-b3fc-2c963f66afa6

  • --output: Allows you to specify the name of the generated test file.

  • --output-dir: Allows you to specify the directory to store the generated test file.

3. Execute Integration Test

You can execute the generated tests without any additional adjustments to the code.

3.1 Set env variable for authentication

Ensure proper authentication for test execution. By default, we expect a Bearer Token but support additional authentication methods. If your API does not require any authentication, you can skip this step and just run the test.

export SKYRAMP_TEST_TOKEN=$your_auth_token

3.2 Run the test

We now run the test using the Robot Framework. You can call the generated Python file either in an existing robot file of yours or leverage the simple wrapper file we generate.

# Prerequisites
pip install robotframework

# Execution of integration test for products/POST 
robot products_POST_integration_test.robot

3.3 Results

As we use the Robot Framework to execute the test in this example, you can expect both the typical stdout from Robot and the generated files (output, log, report). You can find more information on the generated outputs in the Robot documentation.

3.3.1 Successful Test

The generated test passes out of the box.

3.3.2 Test Failure

For this section, we intentionally changed the request body to create a failure. You can find more detailed information about the test failure in the report.html and log.html.

4. Skyramp Test File

This section explains the key elements of the generated tests. This will enable you to make adjustments when needed quickly.

  • At the top of each file, we show when the test was generated and what command was used

  • Below, we import all relevant libraries and specify the URL for all test requests

  • We define a function for the integration test. It consists of:

    • Invocation of Skyramp Client (includes information about the runtime and framework)

    • Definition of the authentication header

    • For each method of the endpoint:

      • If applicable, definition of the request body (based on API schema or sample data)

      • Creation of the request

      • Status Code assertion

Test Execution Behavior

A generated integration test based on an API schema is performing a basic CRUD scenario. It chains the requests by extracting the unique_id from the response body of the POST method.

  • The test will either use sample data from the schema or provided request data from the generate command to define the request body for the POST method.

  • The test will then perform a GET to retrieve the just previously added object. To avoid flakiness due to delays in the backend of the tested service, the test will retry the GET method multiple times.

  • Next, the test will perform a PUT method based on a sample request body from the API schema.

  • Lastly, the test will delete the previously added and adjusted object

4.1 Generated Test

# Generated by Skyramp v0.5.0.af68db77 on 2025-02-13 09:05:34.615764 -0500 EST m=+0.225917418
# Command: skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
# 		--api-schema openapi.json \
# 		--framework robot \
# 		--language python \

# Import of required libraries
import skyramp
import os
import time

# URL for test requests
URL = "https://demoshop.skyramp.dev"

def test_integration():
    # Invocation of Skyramp Client
    client = skyramp.Client(
        framework="robot"
    )
    # Definition of authentication header
    headers = {}
    if os.getenv("SKYRAMP_TEST_TOKEN") is not None:
        headers["Authorization"] = "Bearer " + os.getenv("SKYRAMP_TEST_TOKEN")


    #POST REQUEST 
    
    # Request Body
    products_POST_request_body = r'''{
            "category": "string",
            "description": "string",
            "image_url": "string",
            "in_stock": "strin",
            "name": "string",
            "price": 0
        }'''
    
    # Execute Request
    products_POST_response = client.send_request(
        url=URL,
        path="/api/v1/products",
        method="POST",
        body=products_POST_request_body,
        headers=headers
    )
    # Generated Assertions
    assert products_POST_response.status_code == 201


    # GET REQUEST 
    max_retries = 10
    sleep_time = 5
    for idx in range(max_retries):
        # Execute Request
        products_product_id_GET_response = client.send_request(
            url=URL,
            path="/api/v1/products/{product_id}",
            method="GET",
            headers=headers,
            path_params={"product_id": skyramp.get_response_value(products_POST_response, "id")}
        )
        if products_product_id_GET_response.status_code == 200:
            break
        time.sleep(sleep_time)
    # Generated Assertions
    assert products_product_id_GET_response.status_code == 200

    # PUT REQUEST 
    # Request Body
    products_product_id_PUT_request_body = r'''{
            "category": "string",
            "description": "string",
            "image_url": "string",
            "in_stock": false,
            "name": "string",
            "price": 0
        }'''
    
    # Execute Request
    products_product_id_PUT_response = client.send_request(
        url=URL,
        path="/api/v1/products/{product_id}",
        method="PUT",
        body=products_product_id_PUT_request_body,
        headers=headers,
        path_params={"product_id": skyramp.get_response_value(products_POST_response, "id")}
    )
    # Generated Assertions
    assert products_product_id_PUT_response.status_code == 200

    # Execute Request
    products_product_id_DELETE_response = client.send_request(
        url=URL,
        path="/api/v1/products/{product_id}",
        method="DELETE",
        headers=headers,
        path_params={"product_id": skyramp.get_response_value(products_POST_response, "id")}
    )
    # Generated Assertions
    assert products_product_id_DELETE_response.status_code == 204

if __name__ == "__main__":
    test_integration()

5. Customize Test Generation

This section includes a few additional examples that show different combinations of flags.

5.1 Change of Authentication Header

The additional flags allow you to change the authentication header.

skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
--language python \
--framework robot \
--auth-header X-API-KEY \
--api-schema openapi.json

5.2 Specification of request data

The additional flags allow you to override the POST request data of the test.

data.json

{
  "category": "toys",
  "description": "bear",
  "image_url": "picture",
  "in_stock": true,
  "name": "big bear",
  "price": 10
}

Generate Command

skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
--language python \
--framework robot \
--request-data @data.json \
--api-schema openapi.json

Python

2.1 Generate Command

Skyramp generates test cases for all methods for the specified path/url and its direct children. For cases, where the direct parent path/url has relevant methods, Skyramp will also generate test cases.

We are using https://demoshop.skyramp.dev/api/v1/products as a placeholder here for your <url-to-endpoint>.

skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
--language python \
--framework robot \
--api-schema openapi.json

This command generates two files:

  • products_POST_integration_test.py

  • products_POST_integration_test.robot (simple Robot wrapper file)

The content of the generated test is explained in Section 4 below.

Adjustments

Below are a few flags to customize the test generation. Additional flags are explained here.

  • --runtime: Allows you to specify the environment in which you want the test to run [docker, k8s, local]

  • --auth-header: This flag allows you to specify the key of your authentication header, e.g. --auth-header X-API-KEY. By default, we assume Bearer.

  • --path-params: This flag allows you to override path parameters from your endpoint URL or the pre-defined values in the API schema, e.g. --path-params id=3fa85f64-5717-4562-b3fc-2c963f66afa6

  • --output: Allows you to specify the name of the generated test file.

  • --output-dir: Allows you to specify the directory to store the generated test file.

3. Execute Integration Test

You can execute the generated tests without any additional adjustments to the code.

3.1 Set env variable for authentication

Ensure proper authentication for test execution. By default, we expect a Bearer Token but support additional authentication methods. If your API does not require any authentication, you can skip this step and just run the test.

export SKYRAMP_TEST_TOKEN=$your_auth_token

3.2 Run the test

We now run the test using the Robot Framework. You can call the generated Python file either in an existing robot file of yours or leverage the simple wrapper file we generate.

# Prerequisites
pip install robotframework

# Execution of integration test for products/POST 
robot products_POST_integration_test.robot

3.3 Results

As we use the Robot Framework to execute the test in this example, you can expect both the typical stdout from Robot and the generated files (output, log, report). You can find more information on the generated outputs in the Robot documentation.

3.3.1 Successful Test

The generated test passes out of the box.

3.3.2 Test Failure

For this section, we intentionally changed the request body to create a failure. You can find more detailed information about the test failure in the report.html and log.html.

4. Skyramp Test File

This section explains the key elements of the generated tests. This will enable you to make adjustments when needed quickly.

  • At the top of each file, we show when the test was generated and what command was used

  • Below, we import all relevant libraries and specify the URL for all test requests

  • We define a function for the integration test. It consists of:

    • Invocation of Skyramp Client (includes information about the runtime and framework)

    • Definition of the authentication header

    • For each method of the endpoint:

      • If applicable, definition of the request body (based on API schema or sample data)

      • Creation of the request

      • Status Code assertion

Test Execution Behavior

A generated integration test based on an API schema is performing a basic CRUD scenario. It chains the requests by extracting the unique_id from the response body of the POST method.

  • The test will either use sample data from the schema or provided request data from the generate command to define the request body for the POST method.

  • The test will then perform a GET to retrieve the just previously added object. To avoid flakiness due to delays in the backend of the tested service, the test will retry the GET method multiple times.

  • Next, the test will perform a PUT method based on a sample request body from the API schema.

  • Lastly, the test will delete the previously added and adjusted object

4.1 Generated Test

# Generated by Skyramp v0.5.0.af68db77 on 2025-02-13 09:05:34.615764 -0500 EST m=+0.225917418
# Command: skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
# 		--api-schema openapi.json \
# 		--framework robot \
# 		--language python \

# Import of required libraries
import skyramp
import os
import time

# URL for test requests
URL = "https://demoshop.skyramp.dev"

def test_integration():
    # Invocation of Skyramp Client
    client = skyramp.Client(
        framework="robot"
    )
    # Definition of authentication header
    headers = {}
    if os.getenv("SKYRAMP_TEST_TOKEN") is not None:
        headers["Authorization"] = "Bearer " + os.getenv("SKYRAMP_TEST_TOKEN")


    #POST REQUEST 
    
    # Request Body
    products_POST_request_body = r'''{
            "category": "string",
            "description": "string",
            "image_url": "string",
            "in_stock": "strin",
            "name": "string",
            "price": 0
        }'''
    
    # Execute Request
    products_POST_response = client.send_request(
        url=URL,
        path="/api/v1/products",
        method="POST",
        body=products_POST_request_body,
        headers=headers
    )
    # Generated Assertions
    assert products_POST_response.status_code == 201


    # GET REQUEST 
    max_retries = 10
    sleep_time = 5
    for idx in range(max_retries):
        # Execute Request
        products_product_id_GET_response = client.send_request(
            url=URL,
            path="/api/v1/products/{product_id}",
            method="GET",
            headers=headers,
            path_params={"product_id": skyramp.get_response_value(products_POST_response, "id")}
        )
        if products_product_id_GET_response.status_code == 200:
            break
        time.sleep(sleep_time)
    # Generated Assertions
    assert products_product_id_GET_response.status_code == 200

    # PUT REQUEST 
    # Request Body
    products_product_id_PUT_request_body = r'''{
            "category": "string",
            "description": "string",
            "image_url": "string",
            "in_stock": false,
            "name": "string",
            "price": 0
        }'''
    
    # Execute Request
    products_product_id_PUT_response = client.send_request(
        url=URL,
        path="/api/v1/products/{product_id}",
        method="PUT",
        body=products_product_id_PUT_request_body,
        headers=headers,
        path_params={"product_id": skyramp.get_response_value(products_POST_response, "id")}
    )
    # Generated Assertions
    assert products_product_id_PUT_response.status_code == 200

    # Execute Request
    products_product_id_DELETE_response = client.send_request(
        url=URL,
        path="/api/v1/products/{product_id}",
        method="DELETE",
        headers=headers,
        path_params={"product_id": skyramp.get_response_value(products_POST_response, "id")}
    )
    # Generated Assertions
    assert products_product_id_DELETE_response.status_code == 204

if __name__ == "__main__":
    test_integration()

5. Customize Test Generation

This section includes a few additional examples that show different combinations of flags.

5.1 Change of Authentication Header

The additional flags allow you to change the authentication header.

skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
--language python \
--framework robot \
--auth-header X-API-KEY \
--api-schema openapi.json

5.2 Specification of request data

The additional flags allow you to override the POST request data of the test.

data.json

{
  "category": "toys",
  "description": "bear",
  "image_url": "picture",
  "in_stock": true,
  "name": "big bear",
  "price": 10
}

Generate Command

skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
--language python \
--framework robot \
--request-data @data.json \
--api-schema openapi.json

Python

2.1 Generate Command

Skyramp generates test cases for all methods for the specified path/url and its direct children. For cases, where the direct parent path/url has relevant methods, Skyramp will also generate test cases.

We are using https://demoshop.skyramp.dev/api/v1/products as a placeholder here for your <url-to-endpoint>.

skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
--language python \
--framework robot \
--api-schema openapi.json

This command generates two files:

  • products_POST_integration_test.py

  • products_POST_integration_test.robot (simple Robot wrapper file)

The content of the generated test is explained in Section 4 below.

Adjustments

Below are a few flags to customize the test generation. Additional flags are explained here.

  • --runtime: Allows you to specify the environment in which you want the test to run [docker, k8s, local]

  • --auth-header: This flag allows you to specify the key of your authentication header, e.g. --auth-header X-API-KEY. By default, we assume Bearer.

  • --path-params: This flag allows you to override path parameters from your endpoint URL or the pre-defined values in the API schema, e.g. --path-params id=3fa85f64-5717-4562-b3fc-2c963f66afa6

  • --output: Allows you to specify the name of the generated test file.

  • --output-dir: Allows you to specify the directory to store the generated test file.

3. Execute Integration Test

You can execute the generated tests without any additional adjustments to the code.

3.1 Set env variable for authentication

Ensure proper authentication for test execution. By default, we expect a Bearer Token but support additional authentication methods. If your API does not require any authentication, you can skip this step and just run the test.

export SKYRAMP_TEST_TOKEN=$your_auth_token

3.2 Run the test

We now run the test using the Robot Framework. You can call the generated Python file either in an existing robot file of yours or leverage the simple wrapper file we generate.

# Prerequisites
pip install robotframework

# Execution of integration test for products/POST 
robot products_POST_integration_test.robot

3.3 Results

As we use the Robot Framework to execute the test in this example, you can expect both the typical stdout from Robot and the generated files (output, log, report). You can find more information on the generated outputs in the Robot documentation.

3.3.1 Successful Test

The generated test passes out of the box.

3.3.2 Test Failure

For this section, we intentionally changed the request body to create a failure. You can find more detailed information about the test failure in the report.html and log.html.

4. Skyramp Test File

This section explains the key elements of the generated tests. This will enable you to make adjustments when needed quickly.

  • At the top of each file, we show when the test was generated and what command was used

  • Below, we import all relevant libraries and specify the URL for all test requests

  • We define a function for the integration test. It consists of:

    • Invocation of Skyramp Client (includes information about the runtime and framework)

    • Definition of the authentication header

    • For each method of the endpoint:

      • If applicable, definition of the request body (based on API schema or sample data)

      • Creation of the request

      • Status Code assertion

Test Execution Behavior

A generated integration test based on an API schema is performing a basic CRUD scenario. It chains the requests by extracting the unique_id from the response body of the POST method.

  • The test will either use sample data from the schema or provided request data from the generate command to define the request body for the POST method.

  • The test will then perform a GET to retrieve the just previously added object. To avoid flakiness due to delays in the backend of the tested service, the test will retry the GET method multiple times.

  • Next, the test will perform a PUT method based on a sample request body from the API schema.

  • Lastly, the test will delete the previously added and adjusted object

4.1 Generated Test

# Generated by Skyramp v0.5.0.af68db77 on 2025-02-13 09:05:34.615764 -0500 EST m=+0.225917418
# Command: skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
# 		--api-schema openapi.json \
# 		--framework robot \
# 		--language python \

# Import of required libraries
import skyramp
import os
import time

# URL for test requests
URL = "https://demoshop.skyramp.dev"

def test_integration():
    # Invocation of Skyramp Client
    client = skyramp.Client(
        framework="robot"
    )
    # Definition of authentication header
    headers = {}
    if os.getenv("SKYRAMP_TEST_TOKEN") is not None:
        headers["Authorization"] = "Bearer " + os.getenv("SKYRAMP_TEST_TOKEN")


    #POST REQUEST 
    
    # Request Body
    products_POST_request_body = r'''{
            "category": "string",
            "description": "string",
            "image_url": "string",
            "in_stock": "strin",
            "name": "string",
            "price": 0
        }'''
    
    # Execute Request
    products_POST_response = client.send_request(
        url=URL,
        path="/api/v1/products",
        method="POST",
        body=products_POST_request_body,
        headers=headers
    )
    # Generated Assertions
    assert products_POST_response.status_code == 201


    # GET REQUEST 
    max_retries = 10
    sleep_time = 5
    for idx in range(max_retries):
        # Execute Request
        products_product_id_GET_response = client.send_request(
            url=URL,
            path="/api/v1/products/{product_id}",
            method="GET",
            headers=headers,
            path_params={"product_id": skyramp.get_response_value(products_POST_response, "id")}
        )
        if products_product_id_GET_response.status_code == 200:
            break
        time.sleep(sleep_time)
    # Generated Assertions
    assert products_product_id_GET_response.status_code == 200

    # PUT REQUEST 
    # Request Body
    products_product_id_PUT_request_body = r'''{
            "category": "string",
            "description": "string",
            "image_url": "string",
            "in_stock": false,
            "name": "string",
            "price": 0
        }'''
    
    # Execute Request
    products_product_id_PUT_response = client.send_request(
        url=URL,
        path="/api/v1/products/{product_id}",
        method="PUT",
        body=products_product_id_PUT_request_body,
        headers=headers,
        path_params={"product_id": skyramp.get_response_value(products_POST_response, "id")}
    )
    # Generated Assertions
    assert products_product_id_PUT_response.status_code == 200

    # Execute Request
    products_product_id_DELETE_response = client.send_request(
        url=URL,
        path="/api/v1/products/{product_id}",
        method="DELETE",
        headers=headers,
        path_params={"product_id": skyramp.get_response_value(products_POST_response, "id")}
    )
    # Generated Assertions
    assert products_product_id_DELETE_response.status_code == 204

if __name__ == "__main__":
    test_integration()

5. Customize Test Generation

This section includes a few additional examples that show different combinations of flags.

5.1 Change of Authentication Header

The additional flags allow you to change the authentication header.

skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
--language python \
--framework robot \
--auth-header X-API-KEY \
--api-schema openapi.json

5.2 Specification of request data

The additional flags allow you to override the POST request data of the test.

data.json

{
  "category": "toys",
  "description": "bear",
  "image_url": "picture",
  "in_stock": true,
  "name": "big bear",
  "price": 10
}

Generate Command

skyramp generate integration rest https://demoshop.skyramp.dev/api/v1/products \
--language python \
--framework robot \
--request-data @data.json \
--api-schema openapi.json

© 2025 Skyramp, Inc. All rights reserved.

© 2025 Skyramp, Inc. All rights reserved.

© 2025 Skyramp, Inc. All rights reserved.