Building Data-Driven Web Apps with Flask 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 it's 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.
0:23 For example, how do we like set up the web framework around it if it depends upon things like request object.
0:30 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 So that we can find our bugs.
0:48 There surely are bugs in our web app. Let's make sure we find them and then get rid of them. And that is great.
0:54 That's not the only reason to write tests. These days in modern software development we have a lot of infrastructure in place to help
1:01 with things like continuous deployment and checking code and verifying that we don't step on each others 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.
1:23 Watches a branch or watches for PR's. And when a change comes in it will automatically check it out and build our project.
1:30 And that build probably includes running tests. But if we don't have tests that build passing, what does that mean?
1:36 I actually don't know what it means, in term of Python. Maybe we could install the dependencies register the website. That might be about it.
1:43 Because Python doesn't even have compiling. So this testing in place means that when our automatic builds pass
1:50 that actually says something about the state of our web app. If we're going to go farther, and go with continuous delivery
1:56 and automatically deploy our site when we put it onto a branch in the build passes when we really need some sort of verification with our tests.
2:03 So these tests are important foundational items for so many things that we might do around our project.

Talk Python's Mastodon Michael Kennedy's Mastodon