https://github.com/salmonmode/contextional
A functional testing tool for Python
https://github.com/salmonmode/contextional
functional-testing python test test-automation testing testing-tools tests
Last synced: 4 months ago
JSON representation
A functional testing tool for Python
- Host: GitHub
- URL: https://github.com/salmonmode/contextional
- Owner: SalmonMode
- License: mit
- Created: 2017-02-17T16:13:00.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-28T23:29:17.000Z (over 7 years ago)
- Last Synced: 2025-02-01T01:33:48.239Z (5 months ago)
- Topics: functional-testing, python, test, test-automation, testing, testing-tools, tests
- Language: Python
- Homepage:
- Size: 146 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build status][bs-img]][bs-link]
[![PyPI version][ppv-img]][ppv-link]
[![Docs][docs-img]][docs-link]# Contextional
A context-based functional testing tool for Python## Installation
To install it, just run:
```shell
pip install contextional
```## "contex-tional?"
It's a portmanteau of the words "context" and "functional". These words were chosen because the tool works by using context managers (`with` statements), and allows you to write functional tests (testing as you go).
## What does it do?
Contextional does 3 things:
1. It gives you more organized test output by breaking tests into a hierarchical structure based on how the tests were defined, letting you provide descriptive names for each layer of the hierarchy as well as the tests themselves.
2. It lets you predefine a hierarchy of tests that can be easily reused in as many places as you'd like.
3. It allows you to control the exact order in which your tests and fixtures occur, which can be extremely useful for writing comprehensive, functional test suites where you need to test as you go.## What does it look like?
### code:
```python
from contextional import GCMwith GCM("Predefined Group") as PG:
@GCM.add_test("value is still 2")
def test(case):
case.assertEqual(
GCM.value,
2,
)with GCM("Main Group") as MG:
@GCM.add_setup
def setUp():
GCM.value = 0@GCM.add_test_setup
def testSetUp():
GCM.value += 1@GCM.add_test("value is 1")
def test(case):
case.assertEqual(
GCM.value,
1,
)@GCM.add_test("value is 2")
def test():
assert GCM.value == 2with GCM.add_group("Child Group"):
@GCM.add_setup
def setUp():
GCM.value += 1@GCM.add_test("value is now 3")
def test():
assert GCM.value == 3@GCM.add_teardown
def tearDown():
GCM.value -= 1GCM.includes(PG)
MG.create_tests()
```### output
```
Main Group
value is 1 ... ok
value is 2 ... ok
Child Group
value is now 3 ... ok
Predefined Group
value is still 2 ... ok----------------------------------------------------------------------
Ran 4 tests in 0.008sOK
```[bs-img]: https://travis-ci.org/SalmonMode/contextional.svg?branch=master
[bs-link]: https://travis-ci.org/SalmonMode/contextional
[ppv-img]: https://badge.fury.io/py/contextional.svg
[ppv-link]: https://badge.fury.io/py/contextional
[docs-img]: https://readthedocs.org/projects/pip/badge/
[docs-link]: http://contextional.readthedocs.io/