Day 5 - Toying with TDD

As I said a couple posts ago, there are other topics I’d like to consider during this attempt at the 180Days challenge. One of them is the idea of Test Driven Development, or in other words, ‘test before you publish’. Getting into a good habit of testing everything before it goes out the door is important for a number of reasons, but I won’t get into those here. Instead, I’ll mention what I’m planning to use for testing all of the Django code I’m writing as part of this Udemy class- Selenium with Python. Selenium is a browser test framework, though coupled with Python, it becomes a robust test ‘gate’, or shall I say, an ‘all tests must pass before publishing it’ tool.

Here’s a small sample that tests if you have Selenium working on your system:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

“Test, you must…” –Yoda Jenkins, Lead QA Tester

Jason T Clark

Jason T Clark

Father. Musician. Gamer. Coder.

comments powered by Disqus
rss facebook twitter github youtube mail spotify instagram linkedin