-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Labels
generator bugCauses malformed generated codeCauses malformed generated code
Description
New Issue Checklist
- I updated the framework and generator to the latest version
- I searched the existing GitHub issues and list of common problems
Overview
When a protocol extends AnyObject, the generator does generate a mock for the protocol but the generated mock does not adopt the protocol it is generating for. As a result, we have a mock whose type does not conform the protocol and is unusable in practice.
Example
Failure scenario, UserProject: AnyObject yields a UserProjectMock which does not : UserProject:
public protocol UserProject: AnyObject {
var isFavorite: Bool { get set }
}
// MARK: - Mocked UserProject
public final class UserProjectMock: Mockingbird.Mock {
typealias MockingbirdSupertype = Projects.UserProject
public static let mockingbirdContext = Mockingbird.Context()
public let mockingbirdContext = Mockingbird.Context(["generator_version": "0.20.0", "module_name": "Projects"])
}
Success scenario, bare UserProject yields a UserProjectMock which does : UserProject:
public protocol UserProject {
var isFavorite: Bool { get set }
}
public final class UserProjectMock: Projects.UserProject, Mockingbird.Mock {
typealias MockingbirdSupertype = Projects.UserProject
public static let mockingbirdContext = Mockingbird.Context()
public let mockingbirdContext = Mockingbird.Context(["generator_version": "0.20.0", "module_name": "Projects"])
// MARK: Mocked isFavorite
public var `isFavorite`: Bool {
...
}
}
Expected Behavior
The conformance of a protocol to : AnyObject should not affect the mock generation since the mock is already a class type.
Environment
- Mockingbird CLI version:
0.20.0 - Xcode and Swift version:
swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51) - Package manager: SPM
- Unit testing framework: XCTest
Metadata
Metadata
Assignees
Labels
generator bugCauses malformed generated codeCauses malformed generated code