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.
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 its 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, for example,
0:24 how do we, like, set up the web framework around it
0:26 if it depends upon things like pyramids request object.
0:30 And what are some of the techniques we can use
0:32 to take advantage of stuff the web app
0:34 already provides us, like, the URL structure, and so on.
0:38 Let's begin by asking the question, "Why test?"
0:42 Why should we write tests at all?
0:44 Well, your first response is probably,
0:45 "So that we can find our bugs, there are surely
0:48 "bugs in our web app, let's make sure
0:50 "we find them and then get rid of them."
0:52 And that is great, but that's not
0:53 the only reason to write tests.
0:56 These days in modern software development,
0:57 we have a lot of infrastructure in place
1:00 to help with things like continuous deployment,
1:02 and checking code, and verifying that we don't
1:05 step on each other's feet if we're working on a team,
1:07 things like that, and testing for Python web apps
1:10 is really one of the few verifications
1:13 that we have that we can work with.
1:15 Let's suppose that we have continuous integration,
1:18 which is a system like TeamCity or Travis CI
1:21 that looks at our GitHub repository, watches a branch,
1:23 watches for PRs, and when a change comes in,
1:26 it will automatically check it out
1:28 and build our project, and that build
1:30 probably includes running tests, but if we don't have tests,
1:34 that build passing, what does it mean?
1:35 I actually don't know what it means
1:37 in terms of Python, maybe we could
1:38 install the dependencies, register the website?
1:41 That might be about it, because Python doesn't
1:44 even have compiling, so this testing in place means that
1:48 when our automatic builds pass, that actually says something
1:51 about the state of our web app.
1:53 If we want to go farther, and go with continuous
1:55 delivery and automatic deploy our site
1:58 when we put it onto a branch and the build passes,
2:01 then really need some sort of verification with our test.
2:03 So these tests are important foundational items
2:06 for many things that we might do around our project.