SwiftyMocky icon indicating copy to clipboard operation
SwiftyMocky copied to clipboard

SwiftyPrototype - use SwiftyMocky for fast prototyping

Open amichnia opened this issue 6 years ago • 2 comments

Who uses Carthage probably noticed, that there is new framework being built (SwiftyPrototype). The reason for that is that we need two different and distinctive ways to use SwiftyMocky as a prototyping tool or unit testing tool.

We should investigate that area, and we need some requirements for the prototyping part. Some to start:

  • [x] it needs to run on the device, and not import XCTest
  • [x] we can rename ...Mock to ...Prototype

From the other requirements, just some ideas:

  1. Make it easier to create 'partial' mocks. For prototyping it makes sense to mock parts that are not done yet, and use concrete implementation whenever possible. I see it something like Given(prototype, .method(willUse: concrete))

  2. Refine variables, so they actually "store" a value.

  3. Include new given type, allowing to contain custom logic. Something like:

Given(prototype, .method(param: .any, willReturn: { it, param -> Result in
  // alter prototype state
  // inspect params
  // custom logic
  return result
})

I believe it is connected to #79

I would appreciate any feedback to this topic.

amichnia avatar May 29 '19 14:05 amichnia

I'm currently using SwiftyPrototype as it is. And it's doing it's job very well :-)

To your first idea: I think it should be possible to set a delegate on the prototype itself, which is used for method(...) if the delegate is set and neither Given(prototype, .method(willReturn: ...)) nor Given(prototype, .method(willProduce: ...)) has been called. I do not think that setting the delegate on a per-method-level is very important. On the contrary: If you only have a per-method-level configuration, it leads to more boilerplate in order to configure the prototype to use the delegate for all or many methods.

chkpnt avatar Oct 12 '21 19:10 chkpnt

Well, we definitely need to have a way to replace some mocked methods with actual implementation during the development cycle, +1 for that.

I think I will give SwiftyPrototype more focus doing version 5, it is now just a mediocre twin brother of SwiftyMocky xD

g-amichnia avatar Oct 13 '21 20:10 g-amichnia