Swiftpack.co - johnno1962/SwiftMock as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by johnno1962.
johnno1962/SwiftMock 1.1.0
Mock structs and classes without code modification for testing.
⭐️ 4
🕓 2 years ago
.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: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

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