Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: Testing web apps
Lecture: Why write tests (web)

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Our web app is basically built. All we have left to do is test and deploy it. So, let's talk about testing web applications.
0:09 Now, this is not a chapter on unit testing and all of its benefits in general. The goal is to focus on testing web applications,
0:18 addressing some of the challenges that we'll see that can be hard, of working with web apps, in terms of testing, for example,
0:25 how do we, like, set up the web framework around it if it depends upon things like pyramids request object.
0:31 And what are some of the techniques we can use to take advantage of stuff the web app already provides us, like, the URL structure, and so on.
0:39 Let's begin by asking the question, "Why test?" Why should we write tests at all? Well, your first response is probably,
0:46 "So that we can find our bugs, there are surely "bugs in our web app, let's make sure "we find them and then get rid of them."
0:53 And that is great, but that's not the only reason to write tests. These days in modern software development, we have a lot of infrastructure in place
1:01 to help with things like continuous deployment, and checking code, and verifying that we don't step on each other's feet if we're working on a team,
1:08 things like that, and testing for Python web apps is really one of the few verifications that we have that we can work with.
1:16 Let's suppose that we have continuous integration, which is a system like TeamCity or Travis CI that looks at our GitHub repository, watches a branch,
1:24 watches for PRs, and when a change comes in, it will automatically check it out and build our project, and that build
1:31 probably includes running tests, but if we don't have tests, that build passing, what does it mean? I actually don't know what it means
1:38 in terms of Python, maybe we could install the dependencies, register the website? That might be about it, because Python doesn't
1:45 even have compiling, so this testing in place means that when our automatic builds pass, that actually says something about the state of our web app.
1:54 If we want to go farther, and go with continuous delivery and automatic deploy our site when we put it onto a branch and the build passes,
2:02 then really need some sort of verification with our test. So these tests are important foundational items
2:07 for many things that we might do around our project.

Talk Python's Mastodon Michael Kennedy's Mastodon