Skip to content

AktivCo/swift-mock

Repository files navigation

Russian/Русский

Description

RtMock is a library for generating mocks for writing unit tests.

Requirements

This library requires swift-tools 5.9 and newer.

Installation

Swift Package Manager

Navigate to the SPM section in your project, add a new package, point it to this repository and choose necessary version.

Usage

To use this library first import it

import RtMock

For generating mock class add annotation @RtMock to a protocol declaration

@RtMock
protocol Foo {
    func f()
    var a: Int { get }
}

This will generate a class RtMockFoo that implements protocol. To mock some function call or some property use a corresponding generated field from mock class.

let mockedFoo = RtMockFoo()
mockedFoo.mocked_f_Void = { }
mockedFoo.mocked_a = 0

Features

RtMock supports generating

  • functions with optional and generic parameters and return types
  • optional properties
  • overloaded functions

If function/property with no provided mock value was called during a test, that will trigger error during force unwrap.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages