Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftyPrototype - use SwiftyMocky for fast prototyping #195

Open
2 tasks done
amichnia opened this issue May 29, 2019 · 2 comments
Open
2 tasks done

SwiftyPrototype - use SwiftyMocky for fast prototyping #195

amichnia opened this issue May 29, 2019 · 2 comments

Comments

@amichnia
Copy link
Collaborator

amichnia commented May 29, 2019

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:

  • it needs to run on the device, and not import XCTest
  • 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 amichnia pinned this issue May 29, 2019
@amichnia amichnia self-assigned this Jul 1, 2019
@g-amichnia g-amichnia self-assigned this Jun 19, 2020
@chkpnt
Copy link

chkpnt commented Oct 12, 2021

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.

@g-amichnia
Copy link
Collaborator

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

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

No branches or pull requests

3 participants