mockingbird
mockingbird copied to clipboard
Invalid Redeclaration error when dealing with protocols that support variadics
New Issue Checklist
- [x] I updated my Mockingbird framework and CLI to the latest version
- [x] I searched for existing GitHub issues
Description
Protocols with overloaded functions with a variadic signature and an input array signature leads to redeclarations in the generated code.
Generator Bugs
If the generator produces code that is malformed or does not compile, please provide:
- A minimal example of the original source
public protocol HashidsGenerator {
associatedtype Char
func encode64(_ value: Int64...) -> String?
func encode64(_ values: [Int64]) -> String?
}
- The actual mocking code generated
public final class HashidsGeneratorMock<Char>: Backbone.HashidsGenerator, Mockingbird.Mock {
static var staticMock: Mockingbird.StaticMock { fatalError("See 'Thunk Pruning' in the README") }
public let mockingContext = Mockingbird.MockingContext()
public let stubbingContext = Mockingbird.StubbingContext()
public let mockMetadata = Mockingbird.MockMetadata(["generator_version": "0.16.0", "module_name": "Backbone"])
public var sourceLocation: Mockingbird.SourceLocation? { get { fatalError("See 'Thunk Pruning' in the README") } set { fatalError("See 'Thunk Pruning' in the README") } }
fileprivate init(sourceLocation: Mockingbird.SourceLocation) {
Mockingbird.checkVersion(for: self)
self.sourceLocation = sourceLocation
}
// MARK: Mocked `encode64`(_ `value`: Int64...)
public func `encode64`(_ `value`: Int64...) -> String? { fatalError("See 'Thunk Pruning' in the README") }
public func `encode64`(_ `value`: @escaping @autoclosure () -> [Int64]) -> Mockingbird.Mockable<Mockingbird.FunctionDeclaration, ([Int64]) -> String?, String?> { fatalError("See 'Thunk Pruning' in the README") }
public func `encode64`(_ `value`: Int64...) -> Mockingbird.Mockable<Mockingbird.FunctionDeclaration, ([Int64]) -> String?, String?> { fatalError("See 'Thunk Pruning' in the README") }
// MARK: Mocked `encode64`(_ `values`: [Int64])
public func `encode64`(_ `values`: [Int64]) -> String? { fatalError("See 'Thunk Pruning' in the README") }
public func `encode64`(_ `values`: @escaping @autoclosure () -> [Int64]) -> Mockingbird.Mockable<Mockingbird.FunctionDeclaration, ([Int64]) -> String?, String?> { fatalError("See 'Thunk Pruning' in the README") }
}
- The expected mocking code that should be generated (or a description) Without any of the redundant redeclarations
Environment
- Mockingbird CLI version (
mockingbird version
): 0.16.0 - Xcode and macOS version (are you running a beta?): XCode 12, Mac Catalina
- Swift version (
swift --version
): Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1) - Installation method (CocoaPods, Carthage, from source, etc)
- Unit testing framework (XCTest, Quick + Nimble, etc): XCTest
- Does your project use
.mockingbird-ignore
? No - Are you using supporting source files? To my knowledge, yes.
Hi. Are there any updates on this issue?
@jdschin The dev team is not maintaining the repo as public, I am guessing they are doing a couple of changes/fixes every now and then only if they need it internally. So better write your own mocks than relying on this library or there are alternatives too like https://github.com/Brightify/Cuckoo. Cuckoo is not well maintained either but at least they do not put marketing comparison on their websites like this https://mockingbirdswift.com/feature-comparison