Contribute Media
A thank you to everyone who makes this possible: Read More

Integration and Functional Testing with LiveServerTestCase, Selenium and More



Thursday 2:45 p.m.--3:30 p.m.

Audience level: Intermediate

DESCRIPTION In this talk, I will present LiveServerTestCase, a feature recently added to Django to enable new, comprehensive forms of testing. I will in particular show how to use LiveServerTestCase with browser automators like Selenium to perform integration and functional tests for your Django applications.

ABSTRACT The Django ecosystem has always placed a strong emphasis on testing, partly thanks to a wide range of tools available in Django's own testing framework. One of the most used from those tools is the dummy web client, which allows to emit mock HTTP requests directly to your codebase and to inspect the responses' contents. However, as useful as it is, this dummy client is limited as it does not exercise the full HTTP specification and it cannot effectively reproduce actual user interactions. With the recent introduction of LiveServerTestCase, it is now possible to use sophisticated HTTP libraries like python-requests and browser automators like Selenium to perform your tests in a more comprehensive way. By automatically running a live HTTP server in the background, LiveServerTestCase allows you to write tests ensuring that all layers of your web application properly fit together and that user interactions function well from end to end.

This talk will cover a range of topics to help you get started with the writing of integration and functional tests for your Django applications, including:

A brief history of when and how LiveServerTestCase was added to Django core. A brief review of different browser automators (Selenium,, etc.). Tips for writing, accelerating and debugging Selenium tests. Testing interactive Javascript-based front-ends and user workflows. A demo of the Django core Selenium test suite. Testing RESTful APIs with python-requests. Running Selenium tests in headless mode for continuous integration. Thoughts on when to use, and when not to use, integration and functional tests.


Improve this page