Releases: seanhenry/SwiftMockGeneratorForXcode
Mojave and Xcode 10 Support
- Built against the latest macOS SDK.
- Supports Swift 4.2 syntax
- Fixes issue where app cannot be opened when Xcode app has different name #15
- Supports inferred properties with String, Int, Double, Bool literal types.
var a = "abc" - Supports inferred properties with Array/Dictionary literals with resolvable types or supported literals.
var a = [0, 1, 2] - Supports inferred properties with resolvable initializers.
var a = A() - Supports inferred properties with
asorisexpression.var a = b as Stringorvar a = b is Bool - Supports inferred properties with tuple types with resolvable items or supported literals.
var a = (0, true) - Logs SourceKit errors
Important
Mojave now requires apps to request permission when automating other apps. This app automates Xcode to find the open project directory. Starting with this release you must select OK for the '"Swift Mock Generator for Xcode" wants access to control "Xcode"' alert when you open the app. Check System Preferences -> Security & Privacy -> Privacy -> Automation and make sure Swift Mock Generator is allowed to control Xcode.
Class support I
This is the first release to support mocking classes 🎉
Please note that note that properties with inferred types are not yet supported and are ignored. Mocks with these items should still compile. Support for these are coming soon.
Release notes:
- Generate a mock inheriting from a class.
- Generate a mock inheriting from a class and one or more protocols.
- A convenience initializer is generated and a super initializer is called with default values where possible.
- Unoverridable items like
private,fileprivate,static, andfinalare ignored. - Instance methods from classes are supported including methods with default parameters.
- Properties with explicit type annotations are supported
var myProp: String = "" - Properties with unoverridable setters using
private(set),fileprivate(set)are supported. - Computed properties are supported
var myProp: String { return "" } - Transient properties are supported
var myProp: String {
get { return otherValue }
set { otherValue = newValue }
}
Performance improvements
Thanks to everyone who filled out the survey. It's given me a good idea what to build next... starting with this performance improvements release. The survey is still open if you want to help shape this project. Class support is my next focus.
Release notes:
- Reduces the overall memory footprint.
- Improves resolving performance and caches already resolved items.
- Improves performance of indenting the generated code.
- Efficiently removes and inserts code, greatly shortening the time to generate a nested test double class.
- Indents code using tabs or spaces defined in your Xcode project.
Spies, Stubs and Dummies
I have 5 multiple choice questions for you to help make this plugin better. 60 seconds of your time will really help! Take the survey. Answers are completely anonymous - thanks in advance!
Release notes:
- 'Generate mock' has been renamed to 'Generate spy' to fit in better with test double naming. Important: you may have to reassign your shortcut
- Can now generate a simpler test double when only stubbing is required. Choose 'Generate stub'.
- Can now generate the simplest possible test double; a dummy. Choose 'Generate dummy'.
Multiple Protocols
- Supports a mock conforming to one or many protocols.
- Supports a mock conforming to a protocol who also conforms to other protocols.
- Ignores classes or type which cannot be resolved.
- Removes duplicate initializers, properties and methods from multiple protocols.
- Adds default return type for closures and tuples where possible.
- Supports most initializers (generic initializers not yet supported).
Breaking changes
- No longer calls empty closures automatically. You must now instruct the mock to call empty closures just like you would closures with arguments. Example:
myMock.shouldInvokeEmptyClosure = true
Xcode 9.3
- App and dependencies built using Xcode 9.3 and Swift 4.1
- Fixes issue with automatically detecting projects
New parser
This release swaps SourceKit for a custom Swift parser. This is a huge change so please raise any new issues that you find.
Also in this release:
- Support for methods with where clauses
- Support for methods with generic arguments inside arrays, dictionaries and optionals.
- Stub a throwing method to throw if required.
Generic method support and new icon
- Captures generic parameters as
Any. - Enables stubbing of generic return types.
- New app icon.
- Sends anonymous usage statistics.
Note: where clauses are not supported yet.
Auto-detect Xcode project path
- Attempts to automatically detect the working project directory.
- Option to turn off auto detection and manually override the project path.
Typealias closure support
- Detects closures referenced by typealiases.
- Supports attributed closures referenced by typealiases.