#TestDoubles

Emanuele Panzthepanz@phpc.social
2026-02-08

@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: docs.phpunit.de/en/13.0/test-d

#php #phpunit #testdoubles #phpunit13

2025-12-25

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!

youtu.be/dT3jORSx6C4

#TestableArchitecture #Hexagonal #TestDoubles

2025-01-13

"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

blog.ploeh.dk/2022/10/17/stubs

Todd A. Jacobs | Rubyisttodd_a_jacobs@ruby.social
2024-04-05

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.

stackoverflow.com/questions/78

Jakub Zalasjakub_zalas
2023-10-12

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.

Jakub Zalasjakub_zalas
2023-04-20

What are the worst examples of using you’ve seen? Send me your mocking hell.

Antonello D'Ippolitoantodippo@fosstodon.org
2023-04-07

I wrote something about testing at the boundaries of your application and contract testing
medium.com/@antodippo/testing-
#testautomation #contracttesting #testdoubles

last senpaibig@cons.ivy.io
2023-01-22

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

#testing #testautomation #testdoubles

Test Doubles

Fake / Dummy:
- Actual implementation
- Shortcut

Stub:
- Canned answers
- Independent of test

Spy:
- Like stubs
- Records call

Mock:
- Includes expectations
- Within test setup
J. B. Rainsberger (he)jbrains
2023-01-12

You can use (#mockobjects) without using a library/framework just the same as you can use without a container.

You don't need to feel stuck, even though I can guess how to reached the point of believing you were.

J. B. Rainsberger (he)jbrains
2022-12-27

I routinely see programmers who shy away from using /#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 and one of the often-cited advantages of testing with "the real thing".

blog.thecodewhisperer.com/perm

Jakub Zalasjakub_zalas
2022-12-05

@jbrains have you seen Ian’s talk? youtu.be/EZ05e7EMOLM
Part of advice is to “Both develop and accept against tests written on a port”. They mean a port from hexagonal architecture. They’re strongly against mocks as they think mocks lead to testing implementation details.
I see this trend recently. However, It seems to me that this approach isn’t putting enough pressure on design and encourages bigger steps.

J. B. Rainsberger (he)jbrains
2022-12-05

Further to my recent discussion about / in design, I remember asking this question at a SoCraTes event in Rochegude, France:

"Are method/function expectations an disease?"

(Or something similar.)

The short answer seemed to be this: it's quite OO, but maybe not a disease. In FP we sometimes contort ourselves to turn complicated custom workflows into straightforward function composition, and it's not always worth the effort.

J. B. Rainsberger (he)jbrains
2022-12-03

Further to this idea, whose videos on "evolutionary design without / " would you endorse? I mean you really like them. You found them compelling and convincing. They don't have to be free.

mastodon.social/@jbrains/10943

J. B. Rainsberger (he)jbrains
2022-12-01

I'm mulling hosting an open discussion about the widespread antipathy towards ("#MockObjects"), because I'd like to understand more about why others have this and I don't.

I'm worried about doing this, because people can act in a way that I prefer not to experience, especially when we try to discuss such issues.

I'm curious about three things:

- Would you attend this?
- Would you watch a recording of this after the fact?
- How would you handle the "bad behavior" issue?

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst