Swiftpack.co - Package - 417-72KI/MockUserDefaults

MockUserDefaults

Build Status Platform Version GitHub release Carthage Compatible Swift Package Manager compatible Swift4.2 Swift5 GitHub license

MockUserDefaults is a simple replacement for NSUserDefaults/UserDefaults to make test easier.

Installation

CocoaPods

pod 'MockUserDefaults', '~> 1.2'

Carthage

github "417-72KI/MockUserDefaults" ~> 1.2

SwiftPM (Swift5 only)

.package(url: "https://github.com/417-72KI/MockUserDefaults.git", .upToNextMajor(from: "1.2.0")),

Usage

Objective-C

NSUserDefaults *userDefaults = [NSUserDefaults mockedUserDefaults];
[userDefaults setObject:@"string" forKey:@"key"];

XCTAssertEqualObjects([userDefaults objectForKey:@"key"], @"string");

Swift

let userDefaults: UserDefaults = .mocked
userDefaults.set("string", forKey: "key")

XCTAssertEqual(userDefaults.string(forKey: "key"), "string")

Demo

Dependencies

Tool

  • CocoaPods
    • Bundler
  • Carthage
    • Homebrew
  • XcodeGen
    • Mint
      • Homebrew
  • Fastlane
    • Bundler

Library

  • R.swift
  • RxSwift
  • RxDataSources
  • Nimble
  • Quick

Create project

First time

make init_demo_app

After the first time

make demo_app

Usage

  1. open MockUserDefaultsDemo.xcworkspace
  2. Build and run app (⌘+R) in iPhone / iPad Simulator
  3. Add any keys and values
  4. Run test (⌘+U) in same simulator
  5. Re-run app (⌘+R) in same simulator
  6. You can see that the app isn't affected by the test.

Github

link
Stars: 4

Dependencies

Used By

Total: 0

Releases

Support Swift Package Manager - 2020-01-30 06:31:50

1.2.0

Support `dictionaryRepresentation` - 2019-08-12 05:47:32

Support Swift5 - 2019-05-08 17:06:00

Passing tests with Swift5

Prototype - 2019-04-12 12:58:42