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.03k stars 104 forks source link

Mock a protocol in an SPM dependency framework. #339

Open Konskii opened 1 year ago

Konskii commented 1 year ago

We decided to move from Pods to SPM in new project, but when writing tests and generating mocks we noticed that swiftyMocky can't properly generate mocks for our protocols that inherited from dependency protocols. When we were using Pods we just declared sources path for that dependency in configuration file and all worked perfect. But when using SPM we can't declare path to SPM checkouts, because it's random generated for every machine and looks like this:

~/Library/Developer/Xcode/DerivedData/my-project-name-gcspsuvvozzxfvcfuobdvkxhegra/SourcePackages/checkouts

We can't declare this path in Mockfile because:

  1. It's random generated
  2. SwiftyMocky appends root for all source paths that we declare.

So, how can we generate mocks for protocols that inherited from spm dependency protocols without copying dependency sources to project directly?