seanhenry / SwiftMockGeneratorForXcode

An Xcode extension (plugin) to generate Swift test doubles automatically.
MIT License
748 stars 47 forks source link

Support custom .mustache templates #37

Open remover opened 4 years ago

remover commented 4 years ago

It would be cool if the user of the plugin could format the output from the plugin according to their wishes / standards in relation to naming in particular, i.e. the use of the term ...Spy for captured parameters or to enable the exclusion of some of the generated properties, e.g. the boolean invoked.

This would potentially make it easier for people to switch from a previous mocking tool in order to maintain consistency in their codebase.

seanhenry commented 4 years ago

Hi @remover

Thanks for raising this issue. This is something I've wanted to do for a while. I will try and allocate some time to add support for this soon. I'll post here with any updates.

seanhenry commented 4 years ago

Can you share an example custom mock with me? I need to know what attributes you'll need in your custom moustache files.

remover commented 4 years ago

sure... our mocks are fairly simple:

protocol TestProtocol {
    func doSomething(withValue value: Int) -> Bool
}

public final class MockTestProtocol: TestProtocol {

    // MARK: - Init

    public init(
    ) { 
    }

    // MARK: - doSomething

    public var doSomethingWithValueCallCount = 0
    public var doSomethingWithValueSpy: Int?
    public var doSomethingWithValueStub: Bool? = <# Stub #>

    public func doSomething(withValue value: Int) -> Bool {
        doSomethingWithValueCallCount += 1
        doSomethingWithValueSpy = value
        return doSomethingWithValueStub
    }
}