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.
0:02 All we have left to do is test and deploy it.
0:05 So let's talk about testing web applications.
0:08 Now this is not a chapter on unit testing
0:11 and all of it's benefits in general.
0:14 The goal is to focus on testing web applications.
0:17 Addressing some of the challenges that we'll see
0:19 that can be hard of working with web apps
0:21 in terms of testing.
0:22 For example, how do we like set up the web framework
0:26 around it if it depends upon things like request object.
0:29 And what are some of the techniques we can use
0:31 to take advantage of stuff the web app already provides us
0:35 like the URL structure and so on.
0:38 Let's begin by asking the question, why test?
0:41 Why should we write tests at all?
0:43 Well, your first response is probably
0:45 So that we can find our bugs.
0:47 There surely are bugs in our web app.
0:48 Let's make sure we find them and then get rid of them.
0:51 And that is great.
0:53 That's not the only reason to write tests.
0:55 These days in modern software development
0:57 we have a lot of infrastructure in place to help
1:00 with things like continuous deployment
1:02 and checking code and verifying that we don't step
1:05 on each others feet if we're working on a team.
1:07 Things like that.
1:08 And testing for Python web apps is really one
1:11 of the few verifications that we have that we can work with.
1:15 Let's suppose that we have continuous integration
1:17 which is a system like TeamCity or Travis CI
1:20 that looks at our GitHub repository.
1:22 Watches a branch or watches for PR's.
1:24 And when a change comes in
1:26 it will automatically check it out and build our project.
1:29 And that build probably includes running tests.
1:32 But if we don't have tests
1:33 that build passing, what does that mean?
1:35 I actually don't know what it means, in term of Python.
1:37 Maybe we could install the dependencies
1:39 register the website.
1:41 That might be about it.
1:42 Because Python doesn't even have compiling.
1:45 So this testing in place means
1:47 that when our automatic builds pass
1:49 that actually says something about the state of our web app.
1:53 If we're going to go farther, and go with continuous delivery
1:55 and automatically deploy our site
1:57 when we put it onto a branch in the build passes
2:00 when we really need some sort of verification
2:01 with our tests.
2:02 So these tests are important foundational items
2:05 for so many things that we might do
2:07 around our project.