Skip to main content

Cucumber-style unit testing of Step Functions

Project description

behave-asl

behave-asl is a Python tool for running unit-style behavioral tests against an AWS Step Function. It is built on top of behave.

In the below example, we define a basic state machine with multiple states. We create a feature file that loads the state machine, skips to a step in the middle, then executes a single step. It then validates the current state of the execution.

state-machine.asl

{
    "StartAt": "FirstState",
    "States": {
        "FirstState": {
            "Type": "Pass",
            "Next": "SecondState"
        },
        "SecondState": {
            "Type": "Pass",
            "Next": "ThirdState"
        },
        "ThirdState": {
            "Type": "Pass",
            "Result": "end",
            "End": true
        }
    }
}

features/state-transitions.feature

Feature: States can transition
  Scenario: Go from second to third state
    Given a state machine defined in "state-machine.asl"
    And the execution is currently at the state "SecondState"
    When the state machine executes
    Then the next state is "ThirdState"

  Scenario: Third state is the final state
    Given a state machine defined in "state-machine.asl"
    And the execution is currently at the state "ThirdState"
    When the state machine executes
    Then the execution ended
    And the execution was successful

Advantages

Quick execution

The behave-asl test bed will run very quickly in comparison to the actual time it takes to execute your state machine. This allows you to catch some some mistakes earlier in the development lifecycle. You can validate your JsonPath queries without executing your actual state machine.

Document requirements

Feature files are regularly used in the software development industry to document the requirements for a system.

Skip steps during test cases

behave-asl will allow you to skip steps. This can be very helpful for state machines that have long running steps.

Installation

$ pip install behave-asl

Usage

Project Structure

The asl files can be anywhere in your project. You should have a features directory that contains your feature files. Each feature file should use the .feature extension. You can have subfolders within your features folder to help categorize your features.

state-machine.asl
features/my-first-feature.feature
features/grouping/my-second-feature.feature

CLI

You can run behave-asl without any arguments to run against the current working directory. behave-asl will look for feature files in a subfolder called features

behave-asl

behave-asl is a wrapper around behave. All of behave's command line options are available to behave-asl

More Documentation

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

behave_asl-1.1.0.tar.gz (26.6 kB view details)

Uploaded Source

File details

Details for the file behave_asl-1.1.0.tar.gz.

File metadata

  • Download URL: behave_asl-1.1.0.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.16

File hashes

Hashes for behave_asl-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b4f689ed54aead69ebfb36c7d6763d169bec512a73b9188b09dc1af1a555f4fe
MD5 b6e9b5e8cdb4b415fa42d5f236c1b5fe
BLAKE2b-256 3bdacfd0d6c676cf084f95a9de3001e61739cfe63a7c489946638765c2c9700b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page