We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

System testing with Pytest, Docker, and Flask

Formal Metadata

Title
System testing with Pytest, Docker, and Flask
Title of Series
Number of Parts
132
Author
License
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
The composability of fixtures in pytest is an improvement over traditional xUnit setup/teardown, reducing the incentive to commit testing crimes such as multi-stage and stepwise tests. This is great out of the box for unit tests, but I'm going to show how to combine the power of pytest fixtures with Docker to build high-level integration tests for microservices or other complex systems with multiple components. I'll then build on that to show how to embed mock web services written with Flask right into the test code. With a sample Java application that makes use of some external resources to offer a data processing service I'll first quick an overview of Pytest, Docker, and Flask. Then I'll mix some pre-built code with live test coding to demonstrate how to build high-level system tests which spin up the application and its dependencies in Docker. I'll then mock one of the external dependencies using Flask, allowing the test to control and verify interaction between the system components. Finally I'll show how to wrap the Flask application in a WSGI middleware that lets the test inspect interaction with the mocked service. From a learning and development point of view, building your own is better than re-using someone else's code so I'll show how the support code for these features is relatively simple and how the audience can build it themselves to exactly meet their own needs. And I'll do it all with a sense of fun, a joke or two and maybe a little storytelling.