Chapter 2. Extending Our Functional Test Using the unittest Module
Letâs adapt our test, which currently checks for the default Django âit workedâ page, and check instead for some of the things we want to see on the real front page of our site.
Time to reveal what kind of web app weâre building: a to-do lists site! In doing so weâre very much following fashion: a few years ago all web tutorials were about building a blog. Then it was forums and polls; nowadays itâs all to-do lists.
The reason is that a to-do list is a really nice example. At its most basic it is very simple indeedâjust a list of text stringsâso itâs easy to get a âminimum viableâ list app up and running. But it can be extended in all sorts of waysâdifferent persistence models, adding deadlines, reminders, sharing with other users, and improving the client-side UI. Thereâs no reason to be limited to just âto-doâ lists either; they could be any kind of lists. But the point is that it should allow me to demonstrate all of the main aspects of web programming, and how you apply TDD to them.
Using a Functional Test to Scope Out a Minimum Viable App
Tests that use Selenium let us drive a real web browser, so they really let us see how the application functions from the userâs point of view. Thatâs why theyâre called functional tests.
This means that an FT can be a sort of specification for your application. It tends to track what you might call a User Story, and follows how the user ...
Get Test-Driven Development with Python, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.