seanhenry / SwiftMockGeneratorForXcode

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

Generated code does not follow the enclosing class access control #42

Open GustavoVergara opened 3 years ago

GustavoVergara commented 3 years ago

When code is generated it doesn’t set an access control to anything. This raises a compiler error when both the protocol and the mock class are public/open.

For example, this protocol and class:

public protocol FooProtocol {
    func bar(arg: String) -> Int
}

public class FooSpy: FooProtocol {
    var invokedBar = false
    var invokedBarCount = 0
    var invokedBarParameters: (arg: String, Void)?
    var invokedBarParametersList = [(arg: String, Void)]()
    var stubbedBarResult: Int! = 0

    func bar(arg: String) -> Int {
        invokedBar = true
        invokedBarCount += 1
        invokedBarParameters = (arg, ())
        invokedBarParametersList.append((arg, ()))
        return stubbedBarResult
    }
}

Raises the error: image

seanhenry commented 3 years ago

Hi @GustavoVergara

Thanks for raising this issue. This feature hasn't been implemented yet but I will add it in the next release.