You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
New Issue Checklist
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 aUserProjectMock
which does not: UserProject
:Success scenario, bare
UserProject
yields aUserProjectMock
which does: UserProject
:Expected Behavior
The conformance of a protocol to
: AnyObject
should not affect the mock generation since the mock is already a class type.Environment
0.20.0
swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
The text was updated successfully, but these errors were encountered: