The Art of Unit Testing, Third Edition, Video Edition

The Art of Unit Testing, Third Edition, Video Edition

English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 7h 26m | 1.08 GB

Unit testing is more than just a collection of tools and practices—it’s a state of mind! This bestseller reveals the master’s secrets for delivering robust, maintainable, and trustworthy code.

Thousands of developers have learned to hone their code quality under the tutelage of The Art of Unit Testing. This revised third edition updates an international bestseller to reflect modern development tools and practices, as well as to cover JavaScript.

Inside The Art of Unit Testing, Third Edition you will learn how to:

  • Create readable, maintainable, and trustworthy tests
  • Work with fakes, stubs, mock objects, and isolation frameworks
  • Apply simple dependency injection techniques
  • Refactor legacy code with confidence
  • Test both frontend and backend code

Effective unit tests streamline your software development process and ensure you deliver consistent high-quality code every time. With practical examples in JavaScript and Node, this hands-on guide takes you from your very first unit tests all the way to comprehensive test suites, naming standards, and refactoring techniques. You’ll explore test patterns and organization, working with legacy code and even “untestable” code. The many tool-agnostic examples are presented in JavaScript and carefully designed so that they apply to code written in any language.

The art of unit testing is more than just learning the right collection of tools and practices. It’s about understanding what makes great tests tick, finding the right strategy for each unique situation, and knowing what to do when the testing process gets messy. This book delivers insights and advice that will transform the way you test your software.

The Art of Unit Testing, Third Edition shows you how to create readable and maintainable tests. It goes well beyond basic test creation into organization-wide test strategies, troubleshooting, working with legacy code, and “merciless” refactoring. You’ll love the practical examples and familiar scenarios that make testing come alive as you read. This third edition has been updated with techniques specific to object-oriented, functional, and modular coding styles. The examples use JavaScript.

What’s inside

  • Deciding on test types and strategies
  • Test Entry & Exit Points
  • Refactoring legacy code
  • Fakes, stubs, mock objects, and isolation frameworks
  • Object-Oriented, Functional, and Modular testing styles
Table of Contents

1 Part 1. Getting started
2 The basics of unit testing
3 Defining unit testing, step by step
4 Entry points and exit points
5 Exit point types
6 Different exit points, different techniques
7 A test from scratch
8 Characteristics of a good unit test
9 Integration tests
10 Finalizing our definition
11 Test-driven development
12 Summary
13 A first unit test
14 The library, the assert, the runner, and the reporter
15 What unit testing frameworks offer
16 Introducing the Password Verifier project
17 The first Jest test for verifyPassword
18 Trying the beforeEach() route
19 Trying the factory method route
20 Going full circle to test()
21 Refactoring to parameterized tests
22 Checking for expected thrown errors
23 Setting test categories
24 Summary
25 Part 2. Core techniques
26 Breaking dependencies with stubs
27 Reasons to use stubs
28 Generally accepted design approaches to stubbing
29 Functional injection techniques
30 Modular injection techniques
31 Moving toward objects with constructor functions
32 Object-oriented injection techniques
33 Summary
34 Interaction testing using mock objects
35 Depending on a logger
36 Standard style Introduce parameter refactoring
37 The importance of differentiating between mocks and stubs
38 Modular-style mocks
39 Mocks in a functional style
40 Mocks in an object-oriented style
41 Dealing with complicated interfaces
42 Partial mocks
43 Summary
44 Isolation frameworks
45 Faking modules dynamically
46 Functional dynamic mocks and stubs
47 Object-oriented dynamic mocks and stubs
48 Stubbing behavior dynamically
49 Advantages and traps of isolation frameworks
50 Summary
51 Unit testing asynchronous code
52 Making our code unit-test friendly
53 Dealing with timers
54 Dealing with common events
55 Bringing in the DOM testing library
56 Summary
57 Part 3. The test code
58 Trustworthy tests
59 Why tests fail
60 Avoiding logic in unit tests
61 Smelling a false sense of trust in passing tests
62 Dealing with flaky tests
63 Summary
64 Maintainability
65 Refactoring to increase maintainability
66 Avoid overspecification
67 Summary
68 Part 4. Design and process
69 Readability
70 Magic values and naming variables
71 Separating asserts from actions
72 Setting up and tearing down
73 Summary
74 Developing a testing strategy
75 Test-level antipatterns
76 Test recipes as a strategy
77 Managing delivery pipelines
78 Summary
79 Integrating unit testing into the organization
80 Ways to succeed
81 Ways to fail
82 Influence factors
83 Tough questions and answers
84 Summary
85 Working with legacy code
86 Choosing a selection strategy
87 Writing integration tests before refactoring
88 Summary
89 Monkey-patching functions and modules
90 Monkey-patching functions, globals, and possible issues
91 Ignoring a whole module with Jest is simple
92 Faking module behavior in each test