
Summary 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. About this Book You know you should be unit testing, so why aren't you doing it? If you're new to unit testing, if you find unit testing tedious, or if you're just not getting enough payoff for the effort you put into it, keep reading. The Art of Unit Testing, Second Edition guides you step by step from writing your first simple unit tests to building complete test sets that are maintainable, readable, and trustworthy. You'll move quickly to more complicated subjects like mocks and stubs, while learning to use isolation (mocking) frameworks like Moq, FakeItEasy, and Typemock Isolator. You'll explore test patterns and organization, refactor code applications, and learn how to test "untestable" code. Along the way, you'll learn about integration testing and techniques for testing with databases.
1. Refactoring/Fowler 2. Design Patterns/Gang of Four 3. The Art of Unit Testing/Osherove
Although, the last book (Unit Testing) is C# specific, what I appreciated was the open discussion of using techniques and tools, rather than ideology.
Also note that these days all popular commercial IDEs (Visual Studio, IDEA, Rider) have great builtin support for TDD (for example: automatically running tests after code changes) so manually doing things and thus slow development are a thing of the past...
## Monographs
Test Driven Development By Example (Kent Beck)
Unit Testing: Principles, Practices, and Patterns (Vladimir Khorikov)
The Art of Unit Testing 2nd ed (Roy Osherove)
Working Effectively with Legacy Code (Michael Feathers)
## Various resources
[Unit Testing Best Pratices](https://www.youtube.com/watch?v=k_ItB5btREU&t=2931s&ab_chann...) (Vladimir Khorikov)
[Testing Without Mocks: A Pattern Language](https://www.jamesshore.com/v2/blog/2018/testing-without-mock...) (James Shore)
[TDD Lunch & Learn](https://www.jamesshore.com/v2/projects/lunch-and-learn) (James Shore)
[Test Driven Development - What? Why? And How?](https://www.youtube.com/watch?v=llaUBH5oayw&ab_channel=Conti...) (Dave Farley)
[The 3 Types of Unit Test in TDD](https://www.youtube.com/watch?v=W40mpZP9xQQ&t=22s&ab_channel...) (Dave Farley)
[TDD and the Lump of Coding Fallacy](https://www.geepawhill.org/2018/04/14/tdd-the-lump-of-coding...) (Geepaw Hill)
## Against Unit Tests
[Why Most Unit Testing is Waste](https://rbcs-us.com/documents/Why-Most-Unit-Testing-is-Waste...) (James O Coplien)
[On unit testing and TDD](https://www.youtube.com/watch?v=21JlBOxgGwY&ab_channel=JeruS...) (Jonathan Blow)
Suppose you have to test the irrigation system of a tree in your garden, you want to test how many times and how much water is used, you have two ways to do it:
1) State-based: run the system for a few hours, during which it should water the tree several times. At the end of that time, you check the state of the watered tree: Is the soil moist enough, is the tree well, are the leaves green, etc. (Obviously this is just an example as this test would be complex in real life, but it is to get the idea across).
2) Interaction: We place a flow meter, a device that registers how much water is flowing through the device and at what times. At the end of the day, check that the device has been called the correct number of times, with the correct amount of water each time, and we don't worry about checking the status of the tree.
--------------------------------------
Clean Code (Robert Cecil Martin)
The Art of Unit Testing (Roy Osherove)
Head First Design Patterns (Elisabeth Freeman, Kathy Sierra)
Martin Fowler's blog: https://martinfowler.com/
.
How to gather requirements and write business-readable code:
--------------------------------------
Domain-driven design (Eric J. Evans)
Implementing Domain-Driven Design (Vaughn Vernon)
Patterns, Principles, and Practices of Domain-Driven Design (Scott Millett)
.
Remaining agile and managing your work according to your clients' needs:
--------------------------------------
The art of doing twice the work in half the time (Jeff Sutherland)
The Mythical Man Month (Fred Brooks)