Rubicon 4+

Cleverlance

    • 無料

スクリーンショット

説明

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.

新機能

バージョン 3.0.0

Migrated to Swift Syntax, which fixed many bungs.

アプリのプライバシー

デベロッパである"Cleverlance"は、アプリのプライバシー慣行に、以下のデータの取り扱いが含まれる可能性があることを示しました。詳しくは、デベロッパプライバシーポリシーを参照してください。

データの収集なし

デベロッパはこのアプリからデータを収集しません。

プライバシー慣行は、ご利用の機能やお客様の年齢などに応じて異なる場合があります。詳しい情報

このデベロッパのその他のアプリ