Rubicon 4+
Cleverlance
-
- Free
Screenshots
Description
Swift parser + mock generator + Xcode extension
https://github.com/raptorxcz/Rubicon
Rubicon generates spys, stub, mocks and dummies for protocols. Generating methods for parent protocol is not supported.
example:
input:
protocol Car {
var name: String? { get }
var color: Int { get set }
@MainActor
func go()
func load(with stuff: Int, label: String) throws -> Int
func isFull() -> Bool
func download() async throws -> [String]
}
output:
spy:
final class CarSpy: Car {
struct Load {
let stuff: Int
let label: String
}
var name: String?
var color: Int
var loadThrowBlock: () -> Void?
var loadReturn: Int
var isFullReturn: Bool
var downloadThrowBlock: () -> Void?
var downloadReturn: [String]
var goCount = 0
var load = [Load]()
var isFullCount = 0
var downloadCount = 0
init(color: Int, loadReturn: Int, isFullReturn: Bool, downloadReturn: [String]) {
self.color = color
self.loadReturn = loadReturn
self.isFullReturn = isFullReturn
self.downloadReturn = downloadReturn
}
func go() {
goCount += 1
}
func load(with stuff: Int, label: String) throws -> Int {
let item = Load(stuff: stuff, label: label)
load.append(item)
try loadThrowBlock?()
return loadReturn
}
func isFull() -> Bool {
isFullCount += 1
return isFullReturn
}
func download() async throws -> [String] {
downloadCount += 1
try downloadThrowBlock?()
return downloadReturn
}
}
stub:
final class CarStub: Car {
var name: String?
var color: Int
var loadThrowBlock: () -> Void?
var loadReturn: Int
var isFullReturn: Bool
var downloadThrowBlock: () -> Void?
var downloadReturn: [String]
init(color: Int, loadReturn: Int, isFullReturn: Bool, downloadReturn: [String]) {
self.color = color
self.loadReturn = loadReturn
self.isFullReturn = isFullReturn
self.downloadReturn = downloadReturn
}
func go() {
}
func load(with stuff: Int, label: String) throws -> Int {
try loadThrowBlock?()
return loadReturn
}
func isFull() -> Bool {
return isFullReturn
}
func download() async throws -> [String] {
try downloadThrowBlock?()
return downloadReturn
}
}
dummy:
final class CarDummy: Car {
var name: String? {
get {
fatalError()
}
}
var color: Int {
get {
fatalError()
}
set {
fatalError()
}
}
func go() {
fatalError()
}
func load(with stuff: Int, label: String) throws -> Int {
fatalError()
}
func isFull() -> Bool {
fatalError()
}
func download() async throws -> [String] {
fatalError()
}
}
usage in tests:
let carSpy = CarSpy()
...
let a1 = carSpy.goCount == 1
let a2 = carSpy.load.count == 1
let a3 = carSpy.load[0].stuff == 2
let a4 = carSpy.load[0].label == "name"
https://github.com/raptorxcz/Rubicon
Xcode extension
Xcode extension can generate test doubles for all or just selected protocols in the current file. The resulting test double can be written to the source file or pasteboard.
What’s New
Version 3.0.0
Migrated to Swift Syntax, which fixed many bungs.
App Privacy
The developer, Cleverlance, indicated that the app’s privacy practices may include handling of data as described below. For more information, see the developer’s privacy policy.
Data Not Collected
The developer does not collect any data from this app.
Privacy practices may vary based on, for example, the features you use or your age. Learn More
Information
- Provider
- Cleverlance Enterprise Solutions a.s.
- Size
- 9.7 MB
- Category
- Developer Tools
- Compatibility
-
- Mac
- Requires macOS 13.3 or later.
- Languages
-
English
- Age Rating
- 4+
- Copyright
- © 2022 Cleverlance
- Price
- Free