O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Art of Unit Testing Video Edition

Video Description

"This book is something special. The chapters build on each other to a startling accumulation of depth. Get ready for a treat."
From the Foreword by Robert C. Martin, cleancoder.com

The Art of Unit Testing, Second Edition guides you step by step from writing your first simple tests to developing robust test sets that are maintainable, readable, and trustworthy. You'll master the foundational ideas and quickly move to high-value subjects like mocks, stubs, and isolation, including frameworks such as Moq, FakeItEasy and Typemock Isolator. You'll explore test patterns and organization, working with legacy code, and even "untestable" code. Along the way, you'll learn about integration testing and techniques and tools for testing databases and other technologies.

Inside:
  • Create readable, maintainable, trustworthy tests
  • Fakes, stubs, mock objects, and isolation (mocking) frameworks
  • Simple dependency injection techniques
  • Refactoring legacy code
The examples in the book use C#, but will benefit anyone using a statically typed language such as Java or C++.

Roy Osherove has been coding for over 15 years, and he consults and trains teams worldwide on the gentle art of unit testing and test-driven development. His blog is at ArtOfUnitTesting.com

The best way to learn unit testing from what is now a classic in the field.
Raphael Faria, LG Electronics

Teaches you the philosophy as well as the nuts and bolts for effective unit testing.
Pradeep Chellappan, Microsoft

When my team members ask me how to write unit tests the right way, I simply answer: Get this book!
Alessandro Campeis, Vimar SpA

The single best resource on unit testing.
Kaleb Pederson, Next IT Corporation

NARRATED BY MARK THOMAS

Table of Contents

  1. PART 1 GETTING STARTED
    1. Chapter 1 - The basics of unit testing 00:09:58
    2. Chapter 1 - Properties of a good unit test 00:06:55
    3. Chapter 1 - Drawbacks of nonautomated integration tests compared to automated unit tests 00:07:25
    4. Chapter 1 - What makes unit tests good 00:06:59
    5. Chapter 1 - Test-driven development 00:07:24
    6. Chapter 1 - The three core skills of successful TDD 00:05:41
    7. Chapter 2 - A first unit test 00:08:22
    8. Chapter 2 - Introducing the LogAn project 00:06:03
    9. Chapter 2 - Loading up the solution 00:08:16
    10. Chapter 2 - Writing your first test 00:09:45
    11. Chapter 2 - Refactoring to parameterized tests 00:05:32
    12. Chapter 2 - More NUnit attributes 00:06:08
    13. Chapter 2 - Checking for expected exceptions 00:08:29
    14. Chapter 2 - Testing results that are system state changes instead of return values 00:09:27
  2. PART 2 CORE TECHNIQUES
    1. Chapter 3 - Using stubs to break dependencies 00:06:05
    2. Chapter 3 - Determining how to easily test LogAnalyzer 00:04:50
    3. Chapter 3 - Refactoring your design to be more testable 00:07:59
    4. Chapter 3 - Dependency injection: inject a fake implementation into a unit under test 00:10:08
    5. Chapter 3 - Simulating exceptions from fakes 00:15:07
    6. Chapter 3 - Variations on refactoring techniques 00:03:44
    7. Chapter 3 - Overcoming the encapsulation problem 00:08:00
    8. Chapter 4 - Interaction testing using mock objects 00:09:48
    9. Chapter 4 - The difference between mocks and stubs 00:06:02
    10. Chapter 4 - A simple handwritten mock example 00:03:40
    11. Chapter 4 - One mock per test 00:05:14
    12. Chapter 4 - The problems with handwritten mocks and stubs 00:05:45
    13. Chapter 5 - Isolation (mocking) frameworks 00:05:39
    14. Chapter 5 - Dynamically creating a fake object 00:09:54
    15. Chapter 5 - Simulating fake values 00:08:12
    16. Chapter 5 - Testing for event-related activities 00:06:38
    17. Chapter 5 - Advantages and traps of isolation frameworks 00:09:07
    18. Chapter 6 - Digging deeper into isolation frameworks 00:09:39
    19. Chapter 6 - How profiler-based unconstrained frameworks work 00:07:35
    20. Chapter 6 - Values of good isolation frameworks 00:04:54
    21. Chapter 6 - Ignored arguments by default 00:07:01
    22. Chapter 6 - Isolation framework design antipatterns 00:07:41
  3. PART 3 THE TEST CODE
    1. Chapter 7 - Test hierarchies and organization 00:05:38
    2. Chapter 7 - Anatomy of a build script 00:05:07
    3. Chapter 7 - Triggering builds and integration 00:04:59
    4. Chapter 7 - Mapping out tests based on speed and type 00:05:33
    5. Chapter 7 - Ensuring tests are part of source control 00:08:00
    6. Chapter 7 - Cross-cutting concerns injection 00:04:46
    7. Chapter 7 - Using test class inheritance patterns 00:17:52
    8. Chapter 7 - Creating test utility classes and methods 00:07:13
    9. Chapter 8 - The pillars of good unit tests 00:03:12
    10. Chapter 8 - Writing trustworthy tests 00:12:28
    11. Chapter 8 - Avoiding logic in tests 00:05:22
    12. Chapter 8 - Testing only one concern 00:04:12
    13. Chapter 8 - Assuring code review with code coverage 00:05:30
    14. Chapter 8 - Writing maintainable tests 00:07:09
    15. Chapter 8 - Removing duplication 00:09:42
    16. Chapter 8 - Enforcing test isolation 00:13:55
    17. Chapter 8 - Avoiding multiple asserts on different concerns 00:05:54
    18. Chapter 8 - Comparing objects 00:07:14
    19. Chapter 8 - Writing readable tests 00:05:25
    20. Chapter 8 - Asserting yourself with meaning 00:06:14
  4. PART 4 DESIGN AND PROCESS
    1. Chapter 9 - Integrating unit testing into the organization 00:06:22
    2. Chapter 9 - Identify possible entry points 00:04:34
    3. Chapter 9 - Ways to succeed 00:07:48
    4. Chapter 9 - Aiming for specific goals 00:06:02
    5. Chapter 9 - Realizing that there will be hurdles 00:06:56
    6. Chapter 9 - Tough questions and answers 00:07:41
    7. Chapter 9 - Why is the QA department still finding bugs? 00:08:42
    8. Chapter 10 - Working with legacy code 00:07:10
    9. Chapter 10 - Writing integration tests before refactoring 00:03:06
    10. Chapter 10 - Important tools for legacy code unit testing 00:08:47
    11. Chapter 10 - Read Michael Feathers’s book on legacy code 00:05:01
    12. Chapter 11 - Design and testability 00:05:39
    13. Chapter 11 - Make classes nonsealed by default 00:05:17
    14. Chapter 11 - Pros and cons of designing for testability 00:06:21
    15. Chapter 11 - Alternatives to designing for testability 00:06:21
    16. Chapter 11 - Example of a hard-to-test design 00:04:29
    17. Chapter 11 - Summary 00:05:08