Writing Testable Code

In this course, you'll learn how to write code that is easy to test. These skills will make practices like unit testing and test-driven development easier to accomplish.
Course info
Rating
(148)
Level
Beginner
Updated
May 5, 2017
Duration
2h 2m
Table of contents
Description
Course info
Rating
(148)
Level
Beginner
Updated
May 5, 2017
Duration
2h 2m
Description

Testable code is code that makes automated testing quick, easy, and enjoyable. In this course, Writing Testable Code, you'll learn how to write code that is easy to test. These skills are necessary to refactor code that is difficult to test into code that is easily testable. First, you'll be introduced to testable code, and how creating seams in your code makes code testable. Next, you'll learn a series of best practices that makes testing code easier such as, simplifying object construction, working with dependencies, and managing application state. Finally, you'll explore best practices further by walking through a code demo of each practice so you can see first-hand how they're implemented. These skills will make practices like unit testing significantly easier for you. By the end of this course, you'll have the skills necessary for writing testable code.

About the author
About the author

Matthew is a data science consultant, author, and international public speaker. He has over 17 years of professional experience working with tech startups to Fortune 500 companies. He is a Microsoft MVP, ASPInsider, and open-source software contributor.

More from the author
Deep Learning: The Big Picture
Beginner
1h 27m
8 Feb 2018
Data Science: The Big Picture
Beginner
1h 9m
15 Sep 2017
More courses by Matthew Renze
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi, I'm Matthew Renze with Pluralsight, and welcome to Writing Testable Code. Testable code is code that makes automated testing easy. Unfortunately, most developers never learned how to write code for testability, so they struggle with software practices like unit testing and test-driven development. However, learning how to write code that is easy to test is the first step in making automated testing quick, easy, and even enjoyable. As an overview of this course, first we'll learn about testable code and how creating seams in our code makes our code testable. Then we'll learn a series of best practices that make testing code easier such as simplifying object construction, working with dependencies, and managing application state. For each of these practices, we'll walk through an open-source demo application that applies these practices so you can see first-hand how they are implemented. By the end of this course, you'll have the skills necessary to write code that is easy to test. In addition, practices like unit testing and test-driven development will become significantly easier because you'll have a deep understanding of what makes code testable versus what makes code difficult to test. As an introductory course, there are no prerequisites for this course; however, having basic experience with at least one C-like programming language in unit testing will be beneficial, but it is not required. I'll walk you through everything you'll need to know as we progress throughout this course. So please join us today at Pluralsight and learn how to create code that is easy to test with Writing Testable Code.

Creating Seams in Code
Hello again, and welcome to our next module on writing testable code. I'm Matthew Renze with Pluralsight, and in this module we'll learn how to create seams in our code to make it testable. As an overview of this module, first we'll learn about creating seams in our code. We'll learn what seams are and why creating them makes our code testable. Next, we'll learn about problems that exist for testability when there are no seams in our code. Then, we'll learn how to identify symptoms that our code may be lacking seams for testability. Finally, we'll learn how to refactor untestable code by creating seams to make it testable. So let's get started.

Constructing Testable Objects
Hello again, and welcome to our next module on Writing Testable Code. I'm Matthew Renze with Pluralsight, and in this module we'll learn how to construct objects in ways that are easily testable. As an overview of this module, first we'll learn about constructors and how objects are created. Next, we'll learn about problems that occur when we mix the construction of our objects with their behavior. Then, we'll learn how to identify symptoms that indicate that we're constructing objects in ways that are difficult to test. Finally, we'll learn how to refactor the construction of objects that are difficult to test into ones that make testing easier. So let's get started.

Working with Dependencies
Hello again, and welcome to our next module on Writing Testable Code. I'm Matthew Renze with Pluralsight, and in this module, we'll learn how to work with dependencies in ways that make testing easier. As an overview of this module, first we'll learn about the Law of Demeter, a general practice of object-oriented software for creating loosely coupled code that has quite a few benefits for testability. Next, we'll learn about problems that may occur for testing when we violate the Law of Demeter. Then, we'll learn about symptoms that generally indicate that we may have a testability problem. Finally, we'll look at solutions to refactor these problems to a more testable design.

Managing Application State
Welcome back to Writing Testable Code. I'm Matthew Renze with Pluralsight, and in this module we'll learn how to manage application state in ways that make testing easier. As an overview of this module, first we'll learn about global state. That is, state that exists at the application level. Next, we'll learn about problems that global state creates for testing. Then, we'll learn about symptoms that may indicate that we have testability problems with global state. Finally, we'll learn how to refactor our code to solve these problems with testability. So let's get started.

Maintaining Single Responsibility
Hello again, and welcome to our next module on Writing Testable Code. I'm Matthew Renze with Pluralsight, and in this module we'll learn how maintaining the single responsibility principle helps testability by keeping our tests small and simple. As an overview of this module, first we'll learn about the single responsibility principle and how it applies to writing testable code. Next, we'll learn about problems for testability when we violate this principle. Then, we'll learn how to identify symptoms of single responsibility principle violations. Finally, we'll learn how to refactor these violations to improve testability. So let's get started.

Next Steps
Hello again, and welcome to our final module on Writing Testable Code. I'm Matthew Renze with Pluralsight, and in this module we'll learn about test-driven development and where to go next to learn more about writing testable code. As an overview of this module, first we'll start with a brief introduction to test-driven development. Then, we'll discuss where to go next to learn more about writing testable code. Finally, we'll wrap things up for this module and for the course as a whole. So let's get started.