Scaffolded and added readmes for testing work
This commit is contained in:
parent
863ae3496a
commit
1d0a0c1c17
|
@ -38,6 +38,8 @@ requests==2.25.1
|
||||||
requests-toolbelt==0.9.1
|
requests-toolbelt==0.9.1
|
||||||
rq==1.9.0
|
rq==1.9.0
|
||||||
selenium
|
selenium
|
||||||
|
behave
|
||||||
|
webdriver_manager
|
||||||
six==1.16.0
|
six==1.16.0
|
||||||
SQLAlchemy==1.4.20
|
SQLAlchemy==1.4.20
|
||||||
urllib3==1.26.6
|
urllib3==1.26.6
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
Feature: Add tasks to todo list
|
||||||
|
As a user
|
||||||
|
I want to be able to add tasks to my todo list
|
||||||
|
So thats I can keep track of my work
|
||||||
|
|
||||||
|
Scenario: User visits the todo list page
|
||||||
|
Given the user is on the todo list page
|
||||||
|
Then the page should have a text field to enter the title of the task
|
||||||
|
And the page should have a text field to enter the estimate of hours needed to complete the task
|
||||||
|
And the page should have a button to add the task
|
||||||
|
|
||||||
|
Scenario: Add a new task to the todo list
|
||||||
|
Given I am on the todo list page
|
||||||
|
When I enter "Buy groceries" in the title field
|
||||||
|
And I enter "2" in the estimate field
|
||||||
|
And I click the "Add" button
|
||||||
|
Then the task "Buy groceries" with estimate "2" should be added to the todo list
|
|
@ -0,0 +1,5 @@
|
||||||
|
How to run behave tutorial
|
||||||
|
|
||||||
|
1. Running all behave features
|
||||||
|
|
||||||
|
run " behave tests/features/add-task.feature "
|
|
@ -0,0 +1,38 @@
|
||||||
|
from behave import *
|
||||||
|
from webdriver_manager.chrome import ChromeDriverManager
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.chrome.service import Service as ChromeService
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
|
||||||
|
@given(u'I am on the todo list page')
|
||||||
|
def open_browser(context):
|
||||||
|
context.driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
|
||||||
|
context.driver.implicitly_wait(5)
|
||||||
|
context.driver.get("http://127.0.0.1:5000/")
|
||||||
|
|
||||||
|
|
||||||
|
@when('I enter "{title}" in the title field')
|
||||||
|
def step_impl(context, title):
|
||||||
|
title_field = context.driver.find_element(By.NAME, "title")
|
||||||
|
title_field.send_keys(title)
|
||||||
|
|
||||||
|
|
||||||
|
@when('I enter "{estimate}" in the estimate field')
|
||||||
|
def step_impl(context, estimate):
|
||||||
|
estimate_field = context.driver.find_element(By.NAME, "estimate")
|
||||||
|
estimate_field.send_keys(estimate)
|
||||||
|
|
||||||
|
|
||||||
|
@when(u'I click the "Add" button')
|
||||||
|
def step_impl(context):
|
||||||
|
add_button = context.driver.find_element(By.XPATH, "//button[contains(text(),'Add')]")
|
||||||
|
add_button.click()
|
||||||
|
context.driver.implicitly_wait(5)
|
||||||
|
|
||||||
|
|
||||||
|
@then('the task "{title}" with estimate "{estimate}" should be added to the todo list')
|
||||||
|
def step_impl(context, title, estimate):
|
||||||
|
dump_text = context.driver.page_source
|
||||||
|
print(dump_text)
|
||||||
|
assert ("Buy groceries | 2" in dump_text) is True
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
from behave import *
|
||||||
|
from webdriver_manager.chrome import ChromeDriverManager
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.chrome.service import Service as ChromeService
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
|
||||||
|
|
||||||
|
@given(u'the user is on the todo list page')
|
||||||
|
def open_browser(context):
|
||||||
|
context.driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
|
||||||
|
context.driver.implicitly_wait(5)
|
||||||
|
context.driver.get("http://127.0.0.1:5000/")
|
||||||
|
|
||||||
|
|
||||||
|
@then(u'the page should have a text field to enter the title of the task')
|
||||||
|
def check_task_title_textbox(context):
|
||||||
|
status = context.driver.find_element(By.NAME, "title").is_displayed()
|
||||||
|
assert status is True
|
||||||
|
|
||||||
|
|
||||||
|
@then(u'the page should have a text field to enter the estimate of hours needed to complete the task')
|
||||||
|
def check_task_estimate_textbox(context):
|
||||||
|
status = context.driver.find_element(By.NAME, "estimate").is_displayed()
|
||||||
|
assert status is True
|
||||||
|
|
||||||
|
|
||||||
|
@then(u'the page should have a button to add the task')
|
||||||
|
def check_task_add_button(context):
|
||||||
|
status = context.driver.find_element(By.XPATH, "//button[contains(text(),'Add')]").is_displayed()
|
||||||
|
assert status is True
|
|
@ -0,0 +1,11 @@
|
||||||
|
How to run unit tests
|
||||||
|
|
||||||
|
unit tests must follow the "test*.py" regex to be picked up
|
||||||
|
|
||||||
|
1. Individual tests
|
||||||
|
|
||||||
|
run " python .\tests\unit\test_example.py "
|
||||||
|
|
||||||
|
2. Run all unit tests
|
||||||
|
|
||||||
|
run " python -m unittest discover -s ./tests/unit "
|
|
@ -1,4 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
import sys
|
||||||
|
sys.path.append('./')
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import unittest
|
import unittest
|
||||||
from app import create_app, db
|
from app import create_app, db
|
Loading…
Reference in New Issue