MakeAWishFoundation / SwiftyMocky

Framework for automatic mock generation. Adds a set of handy methods, simplifying testing. One of the best and most complete solutions, including generics support and much more.
MIT License
1.04k stars 106 forks source link

SwiftyMocky is generating AMassiveTestProtocolMock, which is not a protocol in our project #318

Open rserentill opened 2 years ago

rserentill commented 2 years ago

Hello there, We have been using SwiftyMocky for quite some years now and it's been always working wonderfully. However, since today, it is creating mocks for protocols that are not currently in the project.

For example, it is creating a mock for AMassiveTestProtocol by adding a class:

open class AMassiveTestProtocolMock: AMassiveTestProtocol, Mock, StaticMock {
  ...
}

This is not the only mock it's creating, in fact, it has created a lot of them. I found that the protocol AMassiveTestProtocol is inside of the examples folder in the SwiftyMocky package.

Because of this, we are not able to compile tests target because Xcode is complaining about not finding such protocol (Cannot find type 'AMassiveTestProtocol' in scope).

We are generating the mocks from CocoaPods, we've also tried with mint and the outcome is the same.

I'm not sure why is this suddenly happening, we didn't update SwiftyMocky.

Does anyone have an idea of why is this happening?

spaluchiewicz commented 2 years ago

@rserentill could you share more details: SwiftyMocky version, Sourcery version, Mockfile (if possible)?

shurale85 commented 8 months ago

Check the path u specified in mockfile. It seems to scan swifymocky example that contains of AMassiveTestProtocol. So u need exclude swifymocky example path

s-inamori commented 4 months ago

Check the path u specified in mockfile. It seems to scan swifymocky example that contains of AMassiveTestProtocol. So u need exclude swifymocky example path

In my case, the issue occurred because I had multiple projects in my workspace, and one of the projects contained the source code for the SwiftyMocky example. I solved the problem by deleting that folder, or you can add that path to the exclude in the Mockfile.

sourceryCommand: null
unit.tests.mock:
  sources:
    include:
        - ./MyApp
        - ./../../AnotherProject # This project contained the source code for the swifymocky example.
    exclude: []
  output:
    ./MyAppUnitTests/Mocks/Mock.generated.swift
  targets:
    - MyAppUnitTests
  testable: []
  import: []

Here is the location of the swiftymocky example source (the folder I deleted)

AnotherProject/Build/SourcePackages/checkouts/SwiftyMocky

The version information for the tool is as follows: SwiftyMocky version: 4.2.0 Sourcery version: 1.8.0