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):
- Setup
- Main (consists of
Task
andTest
steps) - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file staircase_test-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: staircase_test-0.0.5-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad3c7d62251cc1abd24c9ff176d520c72e535a682f2c49444d1d0e46fc9e867d |
|
MD5 | 20b07834e6d8de6f5d066072f7e357b4 |
|
BLAKE2b-256 | 1891ab92b65d84c4273f4c74914faf5a57a7f3fe81e3096a748326a1ae9018d5 |