Introduction5:10 with Craig Dennis
Let's talk about tests.
[SOUND] Hello, I'm Craig, 0:00 and I'm a developer. 0:04 This course does come with a few prerequisites, so 0:07 please make sure that you are all caught up with those. 0:10 I am going to assume that you, as a Java developer, know what I'm talking about. 0:13 Remember that there are speed controls on the video player, and 0:19 you can always speed up or make me go really slow, and I won't mind at all. 0:21 Also, keep in mind that there are usually pretty 0:27 detailed notes attached to each video. 0:30 I usually will point them out, but don't forget to check them out for 0:33 more juicy knowledge. 0:36 In this course, we are going to explore the wonderful world of automated testing, 0:38 more specifically, unit testing. 0:42 Together, we'll explore the terminology, concepts, 0:45 and many of testing's best practices. 0:48 We'll talk about why, how, and what to test. 0:52 Well, wait a second. 0:57 What about when, you ask. 0:58 Well, we can cover that right now. 1:00 The answer to when should we test is this, always. 1:03 You should always test. 1:07 But, but, but, but we haven't been testing in previous courses. 1:10 I know, right. 1:14 It was killing me. 1:15 By the time we reach the end of this course, 1:17 I hope you'll be in complete agreement with me. 1:19 Testing is a lot of fun, and I know you're gonna have fun with this course. 1:21 Testing your code properly ends up driving a lot of good programming habits home. 1:26 Now, throughout this course, I'm gonna through in a few new object 1:31 oriented techniques that will help your code not only be more extensible, but 1:34 also more testable. 1:39 We'll be using Intelli-J idea to exercise the J unit testing framework. 1:42 If you don't have Intelli-J installed on your machine, 1:47 make sure to check the prerequisites for the local development environments course. 1:49 There are for sure 1:54 other testing frameworks that you might end up working with. 1:55 And every language has its own flavor of testing. 1:57 Just about every one of the concepts that you'll learn in this course 2:01 will be transferable, not only to those other frameworks, but 2:03 also to the other languages. 2:07 There's an inevitable time in every project, and 2:09 it's usually right before the product launches, 2:13 where the dreadful question of are we sure this works is asked. 2:15 Let's take a quick look at how this is answered before testing is in place. 2:19 So the client asks, so we're launching this tomorrow? 2:25 Are you sure that it works? 2:28 And you and your team are like, yeah, totally, sure. 2:30 And the client goes hm, just making sure you all 2:35 thought about what happens when the user didn't provide their last name, right? 2:38 And then the team looks at each other and goes, yeah, totally, uh-huh, 2:43 uh-huh, yeah, yeah, yeah, and then when the meeting's over, 2:48 everyone rushes back to their computers to see what actually happens. 2:52 And they do this by adding console print statements and 2:56 actually booting up a new profile without a last name, 2:58 and then they try to look at all the pages where the user is displayed. 3:01 It turns out the code isn't shared across each page. 3:06 So they decide to split up and tackle each page. 3:09 Now thankfully, several errors are found, 3:12 and everyone starts rushing and submitting their code to the shared code base. 3:15 They all feel good and safe and they high five [SOUND] but then someone says, 3:18 hey, that last change you made ended up breaking this other widget. 3:23 So they start fixing that widget and then they break another thing and 3:28 then that fix breaks another thing. 3:31 Then they end up pushing back launch a couple of weeks. 3:33 But after working lots and lots of long nights, it all finally goes live. 3:36 Phew! 3:41 Now are you ready for 3:43 the real sad part of the story of the team without testing in place? 3:44 The errors start piling in from their users, and 3:47 as the pattern of fix one thing break two more continues, soon they're spending 3:50 most of their time fixing bugs instead of making new features. 3:54 Now let's take a look at a different world, one where testing is in place. 4:00 It's the same story, it's the day before launch, and the client asks, 4:04 so we're launching this tomorrow, are you sure this works? 4:09 And you and your team are like, yep. 4:12 And the client goes, just making sure you all 4:15 thought about what happens when the user didn't provide their last name, right? 4:18 And you respond with, yeah, I'm pretty sure, let me check the test real quick. 4:23 And you open up the User Profile Tests. 4:26 You look at the test name and 4:29 immediately see one that says displayingUserWithFirstNameOnlyShowsFirst. 4:30 And you tell them that the test their passing and 4:35 that anytime we show their name, we use this approach. 4:37 And everyone high fives at the successful launch. 4:40 And then when bugs come in, they're fixed, and 4:42 a test is written to make sure that that error never happens again. 4:45 And all the tests prove that the change didn't break anything else. 4:49 See what a different world you can create? 4:53 Now I realize that this was just a fictionalized reenactment, but 4:56 that's the idea. 5:00 How much better must that confidence feel? 5:01 Don't you want what's behind door number two? 5:04 I want it for you, too! 5:06 Well then, let's get started. 5:08
You need to sign up for Treehouse in order to download course files.Sign up