Check out a free preview of the full Testing Fundamentals course

The "Wrapping Up" Lesson is part of the full, Testing Fundamentals course featured in this preview video. Here's what you'd learn in this lesson:

Steve wraps up the course with some final thoughts about testing. Getting to a comfortable level of test coverage for a team can be difficult if an application is already in production, but the combination of improved testing and refactoring difficult-to-test code will help.

Preview
Close

Transcript from the "Wrapping Up" Lesson

[00:00:00]
>> Steve Kinney: There are many sets of tools. Sometimes, if we think about even some of the things got a little wild in the mocking and subbing part, because, like in that point, that was tools that you can use when your code is hard to test, right? But like, if one breaks apart their code, they break out the data fetching from the component, right?

[00:00:17]
And those are separate pieces, and you kind of start to pull stuff apart into individual pieces that snap together into Voltron instead of, like, are glued together, right? The act of testing something can become as easy as it was in the very beginning. With that, add and subtract and stuff along those lines.

[00:00:33]
Now, I'm not gonna lie to you. Getting there is hard, right. Especially because, like, sure, like this thing already lives in production. And, like, the idea of refactoring is a risk in and of itself, right? You're like, Steve told me that I should break everything apart, so we're gonna stop everything for six months and do that.

[00:00:50]
Yeah, good luck, right? My code base isn't even like that, and there are areas where we, and you know what they are, because everyone on the team, size when it's like sprint planning and it's like touch that part of the code base. You know what I mean? And like, you know, but like those are still the areas where it's like, that is a practice that works.

[00:01:12]
You can't always do it immediately. But a lot of times if something is hard to test and you feel like I can't test this, maybe, maybe like. Getting better at testing is not the answer, right? Maybe it is, that's an area that needs refactoring, right? And like that's an area of tech debt.

[00:01:28]
Or maybe like, can you get the value just by getting a brad. Would you feel better, if on every poll request a browser was firing up and going through that flow at the very least, right? Umm, you're not gonna get that feedback loop. You're gonna do that thing where you get very hopeful when you open up a PR and you watch the build process.

[00:01:47]
And it takes 7, 9, 11 minutes, and then fails. That's not the best feedback loop in the world for getting your job done, but it will get you that coverage so you're not causing outages, right? Versus a unit test that's very fast, but it might involve some refactoring.

[00:02:01]
Yeah, right? You can step out the world, but the more you step out the world, are your tests even useful anymore? You can generate snapshot tests real quick, but like, is everyone gonna ignore it when something's hard to test, it doesn't mean that you don't know how to test it.

[00:02:14]
It just means that it's hard to test, right? It's not that testing is hard. It's like that piece of code is problematic, and I've got them, you've got them, right? You'll make more next over the next year. I will too, right? Umm, because sometimes you're just, like, writing code, you're figuring something out, you get it working.

[00:02:30]
That is the next piece of tech debt, because you know, you you know, in the thought process weren't pulling it apart, like and those are all pieces, and these are just tools for managing this complexity, but if you just leave this course with a belief system that testing could be simple if I make my code simple.

[00:02:46]
And then thinking about like there are a whole bunch of other advantages, making your code simple and reusable, right? And that these are like, like, mutually, like, intertwined problems as well, and that there are strategies and tools, because, like, there are trade offs to some of the easy ways out.

[00:03:01]
But sometimes the easy way out gets you time to do the refactor, you know, and do it if it gets you the confidence, right? Like, know that there are trade offs, and that's an okay thing. If you go in eyes wide open, it's okay. If you do it accidentally.

[00:03:15]
Well, then yeah [INAUDIBLE]. But like, if you understand that the trade offs and that mocking out entire dependencies, it's gonna come back to hurt you some other way. But maybe it's good for right now, okay, you know. Or maybe some playwright tests are good for right now. Or maybe, like, you know, the next thing that you build, you break into those small units, awesome, right?

[00:03:33]
Those are all good approaches, and it means we got the most out of our time together. Thank you. [SOUND].
>> Audience: [APPLAUSE].

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now