seanhenry / SwiftMockGeneratorForXcode

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

Optional properties have a force-unwrapped stub #48

Open mattgapadmi opened 3 years ago

mattgapadmi commented 3 years ago

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?