Top all-time · #2607
Enterprise Craftsmanship
Personal blog · enterprisecraftsmanship.comprogrammingcareer
Enterprise Craftsmanship is a personal blog at enterprisecraftsmanship.com about programming and career. Since 2015, 29 different Hacker News readers have linked it 87 times, most often “When to Mock”. The last post was in 2023, but the archive is still widely read.
Too few sampled comments (8) to say how often HN recommends it.?
Why HN links it
HN readers cite Khorikov's posts on mocking, unit testing and dependencies. They are recommended as a clearer overview than Fowler's mocks article and as guidance for using fewer mocks.
Summarised by Claude from a sample of 8 HN comments that link here. Each comment is marked recommending, critical or neutral (citing without judging); how this works.
Painless Unit Testing
Most-linked posts?
- When to Mock3 people · 5 mentions · first linked 2020-04-15
- SQL vs. NoSQL: you do want to have a relational storage by default3 people · 3 mentions · first linked 2015-11-06
- Growing Object-Oriented Software, Guided by Tests Without Mocks2 people · 3 mentions · first linked 2016-07-05
- How I tried to get into game development and failed2 people · 3 mentions · first linked 2017-07-26
- What is functional programming?2 people · 2 mentions · first linked 2016-04-21
- You are naming your tests wrong2 people · 2 mentions · first linked 2019-08-28
- Growing Object-Oriented Software, Guided by Tests Without Mocks (2016)2 people · 2 mentions · first linked 2021-08-09
- Test-induced design damage or why TDD is so painful2 people · 2 mentions · first linked 2015-06-29
- Law of Demeter and immutability2 people · 2 mentions · first linked 2016-09-29
- TDD best practices2 people · 2 mentions · first linked 2015-08-03
What Hacker News says?
Do you need an ORM? http://enterprisecraftsmanship.com/2015/11/30/do-you-need-an...
Comment linking /2015/11/30/do-you-need-an-orm/
on “Uncle Bob and Silver Bullets”Submitted How I tried to get into game development and failed as a story · 295 points
HN discussion> how are you suppose to "unit test" that you properly increment a varibale before inserting into the DB without mocking the DB? You put the logic that increments that variable into a pure function and unit test the input/output pair. Because it is now decoupled from the database, you don't have to deal with it. > mocks allow you to isolate the unit to be tested. You achieve isolation instead by refactoring to a "pu…
Comment linking /posts/when-to-mock/
on “Don’t mock what you don’t own”Submitted Database versioning best practices as a story · 171 points
HN discussionI see a lot of complaints from you. But I should mention that nhibernate is not even in the dotnet foundation and not supported for .net core ( I visited their site and it mentions dotnet framework). I see this though: https://enterprisecraftsmanship.com/posts/nhibernate-now-sup... So the issue is mostly nhibernate?
Comment linking /posts/nhibernate-now-supports-net-core-2-0/
on “20 Years of .NET”Submitted Unit testing anti-patterns: Structural Inspection as a story · 148 points
HN discussion> The heart of the argument presented is that using mocks in unit tests is problematic (...) If you use real implementations No. As you say, the moment you have a real out-of-process dependency, you no longer have a unit test, but an "integration-with-external world" test. The heart of the argument is to not mock out internal (in-process) business logic. Instead: a) do not use mocks (e.g. leveraging Moq); use fakes…
Comment linking /posts/when-to-mock/
on “Favor real dependencies for unit testing”Submitted C# and F# approaches to illegal states as a story · 95 points
HN discussionHere’s another review / critique of this book, but with a full implementation based on the author’s grievances: https://enterprisecraftsmanship.com/posts/growing-object-ori... . The main point of it is to avoid testing via mocks and to also avoid interfaces that are only there for testing purposes. The end design is extremely simple, and because it has command / query separation, the actual logic is trivially testab…
Comment linking /posts/growing-object-oriented-software-guided-by-tests-without-mocks/
on “Growing object-oriented software vs. what I would do”Submitted Early exit is a tail call optimization of procedural languages as a story · 93 points
HN discussionMight I recommend this overview? https://enterprisecraftsmanship.com/posts/when-to-mock/ I more understand the Martin Fowler article quite well, but only after struggling with it and revisiting it (sporadically) over several years, and I really think this by Mr, Khorikov gives a much clearer, more straightforward overview.
Comment linking /posts/when-to-mock/
on “Mocks Aren't Stubs (2007)”Submitted When to Mock as a story · 59 points
HN discussionCame here to say exactly that. The author is advocating for mockist style of unit testing, which is quite terrible for many, many reasons. What you are describing is classic unit testing, and this is the way to go. Good article and book about it: - https://enterprisecraftsmanship.com/posts/unit-testing-depen... - Unit Testing Principles, Practices, and Patterns
Comment linking /posts/unit-testing-dependencies
on “Evil Unit Testing (2019)”Submitted Make hard coding your default choice as a story · 43 points
HN discussion> How many places in your code create new users, and how many places in your code need to validate users? If the answer is “many,” you have serious design problems that should not be solved by introducing more classes but by restricting how many different areas of code do the same job. Consider an application where you can edit and add users. Consider that you can also add users to groups and remove users from group…
Comment linking /2015/03/20/functional-c-handling-failures-input-errors/
on “Value Objects – DDD with TypeScript”Submitted Law of Demeter and immutability as a story · 41 points
HN discussionI found this set of articles great for using less mocks and creating less brittle tests: https://enterprisecraftsmanship.com/2015/07/06/how-to-do-pai...
Comment linking /2015/07/06/how-to-do-painless-tdd/
on “Observations on the testing culture of test-driven development”Submitted SQL vs. NoSQL: you do want to have a relational storage by default as a story · 16 points
HN discussionSubmitted Law of Demeter and immutability as a story · 9 points
HN discussionSubmitted Test-induced design damage or why TDD is so painful as a story · 5 points
HN discussionSubmitted Growing Object-Oriented Software, Guided by Tests Without Mocks as a story · 4 points
HN discussionSubmitted The most important TDD rule as a story · 4 points
HN discussionSubmitted You are naming your tests wrong as a story · 3 points
HN discussionSubmitted To TDD or not to TDD as a story · 3 points
HN discussionSubmitted OOP, FP, and object-relational impedance mismatch as a story · 3 points
HN discussionSubmitted OOP, FP, and object-relational impedance mismatch as a story · 3 points
HN discussionSubmitted Is SQL a good place for business logic? as a story · 3 points
HN discussionSubmitted Why following software design best practices decreases code complexity as a story · 3 points
HN discussionSubmitted Why following software design best practices decreases code complexity as a story · 3 points
HN discussionSubmitted C# and F# approaches to illegal states as a story · 3 points
HN discussion