Light weight BDD Pattern
Project description
# Light weight BDD Pattern
## Installation
* `pip install -e git://github.com/legshort/mango#egg=mango`
* Uploading to pypi in on WIP(got stuck due to email typo)
## Goal
* Easy to Use
* Compatible with Python unittest
* Compatible with existing test code
* Support Python3
## Next Step
* Register to pypi
* Add CI
* Support pytest
## Usage
* Define regular test class
* Define regular test method with `@mango.given()`
* Define inner `when` method with `@mango.when()`
* Define inner `then` method with `@mango.then()`
* Run python test: `python -m unittest test_file.py`
* No need to call inner `when` and `then` method becuase `given(), when(), then()` decorators will take care of it
### Example
```python
# test_exampel.py
class MangoUseCase(TestCase):
def setUp(self):
self.user = 'jun'
@mango.given('I am logged-in user')
def test_profile(self):
self.given.user_profile = 'my_profile'
self.given.user_photo = 'my_photo'
self.given.notifications_count = 3
self.given.unread_notifications_count = 1
@mango.when('I click profile')
def when_click_profile():
print('click')
@mango.then('I see profile')
def then_profile():
self.assertEqual(self.given.user_profile, 'my_profile')
@mango.then('I see my photo')
def then_photo():
self.assertEqual(self.given.user_photo, 'my_photo')
@mango.when('I click notification')
def when_click_notification():
print('click')
@mango.then('I see 3 notifications')
def then_notification():
self.assertEqual(self.given.notifications_count, 3)
@mango.then('I see 1 unread notification')
def then_unread_notification():
self.assertEqual(self.given.unread_notifications_count, 1)
@mango.given('I am logged-out user')
def test_auth(self):
self.given.status_code = 401
@mango.when('I access profile by url')
def when_access_profile():
print('access profile')
@mango.then('I see 401 error')
def then_error():
self.assertEqual(self.given.status_code, 401)
```
### Run Example
```python
python -m unittest test_example.py
```
## Contributing
### Run Test
```python
python -m unittest tests/test_mango.py
```
## Installation
* `pip install -e git://github.com/legshort/mango#egg=mango`
* Uploading to pypi in on WIP(got stuck due to email typo)
## Goal
* Easy to Use
* Compatible with Python unittest
* Compatible with existing test code
* Support Python3
## Next Step
* Register to pypi
* Add CI
* Support pytest
## Usage
* Define regular test class
* Define regular test method with `@mango.given()`
* Define inner `when` method with `@mango.when()`
* Define inner `then` method with `@mango.then()`
* Run python test: `python -m unittest test_file.py`
* No need to call inner `when` and `then` method becuase `given(), when(), then()` decorators will take care of it
### Example
```python
# test_exampel.py
class MangoUseCase(TestCase):
def setUp(self):
self.user = 'jun'
@mango.given('I am logged-in user')
def test_profile(self):
self.given.user_profile = 'my_profile'
self.given.user_photo = 'my_photo'
self.given.notifications_count = 3
self.given.unread_notifications_count = 1
@mango.when('I click profile')
def when_click_profile():
print('click')
@mango.then('I see profile')
def then_profile():
self.assertEqual(self.given.user_profile, 'my_profile')
@mango.then('I see my photo')
def then_photo():
self.assertEqual(self.given.user_photo, 'my_photo')
@mango.when('I click notification')
def when_click_notification():
print('click')
@mango.then('I see 3 notifications')
def then_notification():
self.assertEqual(self.given.notifications_count, 3)
@mango.then('I see 1 unread notification')
def then_unread_notification():
self.assertEqual(self.given.unread_notifications_count, 1)
@mango.given('I am logged-out user')
def test_auth(self):
self.given.status_code = 401
@mango.when('I access profile by url')
def when_access_profile():
print('access profile')
@mango.then('I see 401 error')
def then_error():
self.assertEqual(self.given.status_code, 401)
```
### Run Example
```python
python -m unittest test_example.py
```
## Contributing
### Run Test
```python
python -m unittest tests/test_mango.py
```
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
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for apple_mango-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 481ab68cbadcaf05799a826986910ede9137f1f58c1c6c06b95bf4a4239b4b64 |
|
MD5 | ce19699bde1c9e09a31288d880e2d57a |
|
BLAKE2b-256 | dd8431bec0af333bd300a03d2f7a7f560847209a842dcce7e1eb334ca52933c3 |