Swiftpack.co -  johnno1962/SwiftMock as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
johnno1962/SwiftMock
Mock structs and classes without code modification for testing.
.package(url: "https://github.com/johnno1962/SwiftMock.git", from: "1.1.0")

SwiftMock

Mock structs and classes without code modification for testing.

SwiftMock is an experimental package which allows you to interpose a struct or class in the place of an existing one used in your application so you can, for example, provide mocked data for testing or development. The api is simple:

SwiftMock.pose(MockedStruct.self, as: OriginalStruct.self)

The mocking struct must have the same memory layout as the original and mocking classes should inherit from the class being mocked.

To be able to do this, you need to have added "Other Linker Flags" of "-Xlinker -interposable" (without the quotes) to make symbol references "indirect" so they can be redirected. This package also patches a class' vtables. It doesn't currently work with generics.

$Date: 2021/04/29 $

GitHub

link
Stars: 4
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Related Packages

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API