Skip to content

In order to speed up prototyping and development of a story suite, the structure of your YAML data specified in preconditions, parameters and step arguments need not be strictly defined in advance.

All story data that is parsed without a validator is parsed either as a dict, list or string.

It is nonetheless still recommended that you apply validators as soon as possible. See more about that here.

Code Example


Create files:
    files created:
        some text
    - Create file:
          file name: step1.txt
          content: some other text

from hitchstory import BaseEngine, GivenDefinition, GivenProperty

class Engine(BaseEngine):
    given_definition = GivenDefinition(

    def set_up(self):
        for filename, contents in self.given['files_created'].items():
            with open(filename, 'w') as handle:

    def create_file(self, details):
        with open(details['file name'], 'w') as handle:

With code:

from hitchstory import StoryCollection
from pathlib import Path
from engine import Engine
StoryCollection(Path(".").glob("*.story"), Engine()).named("Create files").play()

Will output:

RUNNING Create files in /path/to/working/example.story ... SUCCESS in 0.1 seconds.

File preconditionfile.txt should now contain:

some text

File step1.txt should now contain:

some other text

Executable specification

Documentation automatically generated from gradual-typing.story storytests.