Clean-Swift / CleanStore

A sample iOS app built using the Clean Swift architecture. Clean Swift is Uncle Bob's Clean Architecture applied to iOS and Mac projects. CleanStore demonstrates Clean Swift by implementing the create order use case described by in Uncle Bob's talks.
https://clean-swift.com/clean-swift-ios-architecture/
MIT License
1.91k stars 315 forks source link

Why tested protocols are suffixed by Spy and not Mock ? #32

Open vince4 opened 3 years ago

vince4 commented 3 years ago

I try to understand the difference between Mock and Spy in Unit Test. I found in CleanStore that every mock/spy is suffixed with Spy. But in this article, it's explained that Spy are real objects whereas Mock, new test objects doing nothing :

The difference is that in mock, you are creating a complete mock or fake object while in spy, there is the real object and you just spying or stubbing specific methods of it.

An exemple of Mock in CleanStore :

class ListOrdersPresentationLogicSpy: ListOrdersPresentationLogic
  {
    // MARK: Method call expectations

    var presentFetchedOrdersCalled = false

    // MARK: Spied methods

    func presentFetchedOrders(response: ListOrders.FetchOrders.Response)
    {
      presentFetchedOrdersCalled = true
    }
  }

So should you rename ListOrdersPresentationLogicSpy to ListOrdersPresentationLogicMock, or did I misunderstood something ?