Automatically generates a mock class implementing a specific protocol. For each protocol method, the mock will provide a methodNameCalled
boolean.
Files:
DataService.swift
- sample filelens.stencil
- sourcery templateDataServiceMock.swift
- sample mock generated
You will need sourcery template for this to work.
- Function parameters that are
@escaping
closures will produce a compiler error when declaring therecievedArguments
tuple, because functions tuples are implicitly escaping, so there's no need for@escaping
. To fix this, simply remove the@escaping
from the declaration. - For now, only protocol methods will be mocked. Variables are coming!
- Overloaded methods will produce compiler warnings since they have the same name.
Suggestions and improvements are welcome!
Inspired by Filip Zawada.