Testing with Doubles: Why, When, and How? | The PHP Consulting Company

So you want to test a unit of code that depends on other units of code. When should you replace the real dependencies with Test Stubs or Mock Objects? When should you let the code under test collaborate with the real depended-on units of code? Come to this presentation and learn the ins and outs of stubs and mocks. By the end of this presentation, you will understand how PHPUnit's test double functionality works and which parts of it you should stay clear of.

Developers should consider using #FakeObjects instead of #MockObjects!

Fake objects offer similar isolation benefits while driving high confidence, clear documentation & loose coupling between implementation and test code.

#InfoQ article by Tyson Gern: http://bit.ly/3mfL9Wc

#UnitTesting #SoftwareTesting #DevOps

The Unit in Unit Testing

In this article, we will focus on how developers should consider using fake objects, which offer similar isolation benefits while driving high confidence, clear documentation and more.

InfoQ

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.

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

"Are method/function expectations an #OOP 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.

#lightweight #evolutionarydesign #tdd

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

#lightweight #EvolutionaryDesign #tdd

https://mastodon.social/@jbrains/109438581624133795

@jbrains I would attend. I'm still a fan of using #MockObjects. My experience has been that the people who follow the "London" testing style (Nat Pryce and others) tend to like using them, while the people who follow the "Chicago" testing style (Sandi Metz, David Bernstein, and others) tend to not like using them.

I'm mulling hosting an open discussion about the widespread antipathy towards #TestDoubles ("#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?