SwiftMockGeneratorForXcode icon indicating copy to clipboard operation
SwiftMockGeneratorForXcode copied to clipboard

Optional properties have a force-unwrapped stub

Open mattgapadmi opened this issue 4 years ago • 0 comments

Given a protocol with an optional property like:

protocol MyProtocol {
  var myProperty: String? { get }
}

The following non-optional stubbed value is generated:

    var invokedMyPropertyGetter = false
    var invokedMyPropertyGetterCount = 0
    var stubbedMyProperty: String!

    var myProperty: String? {
        invokedMyPropertyGetter = true
        invokedMyPropertyGetterCount += 1
        return stubbedMyProperty
    }

Would it be possible for optional properties to have optional stubbed values?

mattgapadmi avatar Feb 17 '21 13:02 mattgapadmi