Merry Christmas, to those who celebrate!
As a gift, the recording of my talk on "Testable Architecture" that I recently gave at the Calgary Software Crafters meetup is now available!

@phpunit @ssemicolons oh, missed that! Thank you for the heads up!
Looks like a really useful addition! Thanks @sebastian !
For reference, here is the feature's documentation: https://docs.phpunit.de/en/13.0/test-doubles.html#sealed-test-doubles
Merry Christmas, to those who celebrate!
As a gift, the recording of my talk on "Testable Architecture" that I recently gave at the Calgary Software Crafters meetup is now available!

"You need tests that don't break when you refactor. When you use dynamic mocks, tests tend to fail whenever you make changes in SUTs. Even though you have tests, they don't enable refactoring."
#softwareengineering #softwarearchitecture #tdd #unittests #mocks #testdoubles
https://blog.ploeh.dk/2022/10/17/stubs-and-mocks-break-encapsulation/
I'm not trying to pick on #mockists, but as I point out in this #StackOverflow comment, mocks, #testdoubles, and stubbed methods don't always add value. In addition, this approach requires the rspec-mocks gem in addition to #RSpec core and expectations to create an RSpec::Mocks::Double, plus `allow(dbl).to receive` just to `expect(dbl).to receive`.
This is a layer of overhead and test indirection that is often unnecessary IMHO. YMMV, but it's often worth rethinking.
If people actually read “XUnit Test Patterns: Refactoring Test Code” by G. Meszaros maybe they’d understand what test doubles are, or when/why to use them. Maybe they wouldn’t write how they hate “mocks”, but focused on merits of their approach.
There’s so much misunderstanding and non-constructive criticism in our profession. I really admire those few people I know who strive to write from a positive angle. I’m not sure if I’d be able to doit.
Breakdown of test doubles.
Test Doubles
Fake / Dummy:
- Actual implementation
- Shortcut
Stub:
- Canned answers
- Independent of test
Spy:
- Like stubs
- Records call
Mock:
- Includes expectations
- Within test setup
You can use #TestDoubles (#mockobjects) without using a library/framework just the same as you can use #DependencyInjection without a container.
You don't need to feel stuck, even though I can guess how to reached the point of believing you were.
I routinely see programmers who shy away from using #TestDoubles/#MockObjects in their work. You can find so many strong opinions on the topic!
Let me offer another way to interpret one of the often-cited drawbacks of #TestDoubles and one of the often-cited advantages of testing with "the real thing".
https://blog.thecodewhisperer.com/permalink/a-matter-of-interpretation-with-mock-objects