Skip to main content

Type-safe, YAML-based BDD, TDD & specification by example framework for python.

Project description

HitchStory is a python library for running executable specifications.

Storyfile is a YAML based DSL for writing BDD-style executable user stories for any kind of software.

Dogfooded for years on high and low level software.

The stories are designed to be:

  • Readable

  • Declarative

  • DRY as sand

  • Strongly typed and syntactically sound StrictYAML

  • Parameterized and useable with hypothesis to do property based testing.

  • Self rewriting (without magic)

  • Used to generate pretty documentation for users, stakeholders, translators, managers, etc.

  • 100% buzzword compliant.

Hate writing tests? Hate writing documentation? Made to feel guilty about it?

Prefer writing specifications?

Yeah, me too.

Note

It is currently in ALPHA. APIs may change without warning until version >= 1.0.

Only runs in python 3, but still able to test python 2 code.

Example

email.story:

Log in:
  given:
    website: /login                # preconditions
  steps:
    - Fill form:
        username: (( name ))       # parameterized steps
        password: (( password ))
    - Click: login
  with:
    name: AzureDiamond             # default parameters for story
    password: hunter2


Send email:
  based on: log in                 # continues from test above
  steps:
    - Click: new email
    - Fill form:
        to: Cthon98@aol.com
        contents: |                # long form text
          Hey guys,

          I think I got hacked!
    - Click: send email
    - Email was sent

Corresponding python story engine and runner code:

from hitchstory import BaseEngine, StoryCollection
from tellurium import CyberDriver
from emailchecker import email_was_sent

class Engine(BaseEngine):
    def set_up(self):
        self.driver = CyberDriver()
        self.driver.visit(
            "http://localhost:5000{0}".format(self.given['website'])
        )

    def fill_form(self, **textboxes):
        for name, contents in textboxes.items():
            self.driver.fill_form(name, contents)

    def click(self, name):
        self.driver.click(name)

    def email_was_sent(self):
        email_was_sent()

StoryCollection(["email.story"], Engine()).named("Send email").play()

Install

To install:

$ pip install hitchstory

Why not X instead?

Since hitchstory is, in some sense, a reinvented wheel, some justification is needed (TODO):

  • Why not just write unit tests (e.g with py.test)?

  • Why not use Cucumber / Behat / Lettuce / pytest-bdd?

  • Why not use mamba / flowp?

  • Why not use robot framework?

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

hitchstory-0.7.4.tar.gz (13.7 kB view details)

Uploaded Source

File details

Details for the file hitchstory-0.7.4.tar.gz.

File metadata

  • Download URL: hitchstory-0.7.4.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hitchstory-0.7.4.tar.gz
Algorithm Hash digest
SHA256 8e5f016ad091c19fb5661c1e91d951094f49aa8f018de3423843cd5330ce5670
MD5 24895e4a96e6f060e705eca2fa83612c
BLAKE2b-256 80b3324d221f038e8c3c8ebcf40c489869c82d5a459106a729098270afb3869d

See more details on using hashes here.

Supported by

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