Sign inSign up

jersobh/flower

By jersobh

•Updated over 2 years ago

A flow-driven testing framework for quickly testing REST APIs.

Image
Integration & delivery
API management
Developer tools
0

193

jersobh/flower repository overview

⁠Flower API Testing Framework

This testing framework is designed to facilitate automated testing of RESTful APIs through configurable YAML or JSON files. It supports making HTTP requests, asserting response data, and dynamically managing test data.

⁠Features

  • Allows assertions on response status codes, headers, and body content.
  • Supports dynamic data through context, allowing data from one response to be used in subsequent requests.
  • Configurable through YAML or JSON files for easy test management and readability.

⁠Writing Test Configurations

Test configurations are defined in YAML or JSON files. Here's an example configuration for testing post creation and retrieval:

⁠YAML configuration
testPostLifecycle:
  - name: "Create a New Post"
    url: "https://jsonplaceholder.typicode.com/posts"
    method: "POST"
    params:
      title: 'foo'
      body: 'bar'
      userId: 1
    assertions:
      - type: "equal"
        target: "status"
        expected: 201
      - type: "equal"
        target: "data.title"
        expected: "foo"
    saveToContext:
      postId: "data.id"
⁠JSON configuration
{
    "testPostLifecycle": [
        {
            "name": "Create a New Post",
            "url": "https://jsonplaceholder.typicode.com/posts",
            "method": "POST",
            "params": {
                "title": "foo",
                "body": "bar",
                "userId": 1
            },
            "assertions": [
                {
                    "type": "equal",
                    "target": "status",
                    "expected": 201
                },
                {
                    "type": "equal",
                    "target": "data.title",
                    "expected": "foo"
                }
            ],
            "saveToContext": {
                "postId": "data.id"
            }
        }
    ]
}

⁠Running Tests

To run your tests, execute the test runner from the command line:

cd /path/to/tests/directory
docker run -v $(pwd):/flower/tests jersobh/flower:latest

⁠Test Configuration Options

  • name: A descriptive name for the test step.
  • url: The URL for the HTTP request.
  • method: The HTTP method (e.g., GET, POST).
  • params: Parameters to be sent with the request. For GET requests, these are query parameters. For POST requests, this is the request body.
  • assertions: A list of conditions to assert on the response.
  • saveToContext: Specifies response data to save to the context for use in later test steps.

⁠Assertions

The framework supports several assertion types:

  • equal: Asserts that the target value is equal to the expected value.
  • include: Asserts that the target string or array includes the expected value.
  • greaterThan, lessThan: Asserts numerical comparisons.
  • deepEqual: Asserts deep equality of objects or arrays.
  • notEqual, isNull, isNotNull, isTrue, isFalse: Assert specific conditions.

⁠Contributing

Contributions to this testing framework are welcome. Please submit a pull request or create an issue for any features, fixes, or improvements.

Github: https://github.com/jersobh/flower⁠

Tag summary

Content type

Image

Digest

sha256:a362c596e…

Size

415.5 MB

Last updated

over 2 years ago

docker pull jersobh/flower