seanhenry / SwiftMockGeneratorForXcode

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

Unexpected behavior when generating spies #24

Closed joshwoods closed 5 years ago

joshwoods commented 5 years ago

Example:

protocol UIApplicationInterface: AnyObject {
    func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey: Any], completionHandler completion: ((Bool) -> Void)?)
}

extension UIApplication: UIApplicationInterface { }

Returned generated code:

class TestApplication: UIApplicationInterface {
    var invoked = false
    var invokedCount = 0
    func {
        invoked = true
        invokedCount += 1
    }
}

Please let me know if there is anything else you'd need from me! :)

seanhenry commented 5 years ago

Hi @joshwoods

Thanks for raising this issue. I've been able to reproduce this. It looks like the parser thinks open is a keyword and is not parsing the function correctly.

I'm looking into a fix and I will update here when it's ready.

seanhenry commented 5 years ago

This is now fixed 🎉 You can download the latest version here

joshwoods commented 5 years ago

oh wow, what a super quick turnaround, thanks @seanhenry!