Bump version to 1.5.3
A minimal method stub for Swift.
import Stubber final class StubUserService: UserServiceProtocol { func follow(userID: Int) -> String { return Stubber.invoke(follow, args: userID) } func edit(userID: Int, name: String) -> Bool { return Stubber.invoke(edit, args: (userID, name)) } } func testMethodCall() { // given let userService = StubUserService() Stubber.register(userService.follow) { userID in "stub-\(userID)" } // stub // when userService.follow(userID: 123) // call // then XCTAssertEqual(Stubber.executions(userService.follow).count, 1) XCTAssertEqual(Stubber.executions(userService.follow)[0].arguments, 123) XCTAssertEqual(Stubber.executions(userService.follow)[0].result, "stub-123") }
When a function contains an escaped parameter, use escaping() on arguments.
escaping()
func request(path: String, completion: @escaping (Result) -> Void) { - Stubber.invoke(request, args: (path, completion)) + Stubber.invoke(request, args: escaping(path, completion)) }
pod 'Stubber'
Stubber is under MIT license. See the LICENSE for more info.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
Stubber
A minimal method stub for Swift.
At a Glance
Escaping Parameters
When a function contains an escaped parameter, use
escaping()
on arguments.Installation
License
Stubber is under MIT license. See the LICENSE for more info.