Skip to main content

Simple step-based testing framework.

Project description

staircase

A simple, step-based testing framework.

Useful for tests with complex setups, teardowns, and dependencies between the tests.

Getting Started

Defining A Test

Tests are defined in staircase via classes that inherit from the base test class.

from staircase import StaircaseTest


class MyTest(StaircaseTest):
    pass

Adding Steps

Steps in staircase are broken up into 3 main "flights" (groups of steps):

  1. Setup
  2. Main (consists of Task and Test steps)
  3. Teardown

All qualifying Setup steps are run before any main steps (Task and Test), and those steps are run before any qualifying Teardown steps.

Steps are defined as methods on the class and wrapped in decorators that designate their type.

Steps return a tuple or a pass/fail bool:

  • return pass/fail bool, return value
  • return pass/fail bool (None return value)
from staircase import StaircaseTest, Setup, Task, Test, Teardown


class MyTest(StaircaseTest):
    @Setup
    def my_setup_step(self):
        return True, 'Successfully setup.'

    @Task
    def prime_the_file(self):
        return True

    @Test
    def file_has_correct_contents(self):
        return True

    @Teardown
    def delete_artifacts(self):
        try:
            self._delete('...')
            return True
        except:
            return False, 'Exception occurred'

Dependencies can also be added between the steps. They will only run if their dependency passes or fails, depending on the specified condition. Steps without dependencies will be run in an arbitrary order (within their respective flights).

from staircase import StaircaseTest, Setup, Task, Test, Teardown


class MyTest(StaircaseTest):
    @Setup
    def my_setup_step(self):
        return True, 'Successfully setup.'

    @Task(on_pass='my_setup_step')
    def prime_the_file(self):
        return True

    @Test
    def file_has_correct_contents(self):
        return True

    @Teardown(desc='Delete unprimed file', on_fail='prime_the_file')
    def delete_artifacts(self):
        try:
            self._delete('...')
            return True
        except:
            return False, 'Exception occurred'

Running Tests

Tests can be run by instantiating the class and calling the run method.

test = MyTest()
test.run()

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

staircase_test-0.0.5-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file staircase_test-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for staircase_test-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ad3c7d62251cc1abd24c9ff176d520c72e535a682f2c49444d1d0e46fc9e867d
MD5 20b07834e6d8de6f5d066072f7e357b4
BLAKE2b-256 1891ab92b65d84c4273f4c74914faf5a57a7f3fe81e3096a748326a1ae9018d5

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