SwiftMockGeneratorForXcode icon indicating copy to clipboard operation
SwiftMockGeneratorForXcode copied to clipboard

Support custom .mustache templates

Open remover opened this issue 4 years ago • 3 comments

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.

remover avatar Jun 19 '20 13:06 remover

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 avatar Jun 19 '20 14:06 seanhenry

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

seanhenry avatar Jun 19 '20 14:06 seanhenry

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
    }
}

remover avatar Jun 19 '20 16:06 remover