Skip to content

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

Description

@vince4

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 ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions