Go to file
417-72KI 3fa775f070 sort 2022-04-03 02:10:28 +09:00
.github add workflow 2022-04-02 04:02:56 +09:00
DemoApp move UI files to App 2022-04-02 02:52:08 +09:00
Sources/MockUserDefaults replace Info.plist 2021-09-04 00:56:59 +09:00
Tests requires Xcode 11 2021-09-04 01:54:50 +09:00
scripts sort 2022-04-03 02:10:28 +09:00
.gitignore save ResultBundle as artifact 2022-04-01 12:33:12 +09:00
LICENSE Initial commit 2019-04-12 16:35:06 +09:00
Makefile save ResultBundle as artifact 2022-04-01 12:33:12 +09:00
MockUserDefaults.podspec Bump version to 1.3.1 2022-03-08 16:23:02 +09:00
Package.swift fix tvOS support to v11.0 and add watchOS support 2021-09-05 15:45:51 +09:00
README.md update README 2022-04-01 20:25:05 +09:00
versions.json drop Xcode 11.7 2022-03-30 03:47:51 +09:00

README.md

MockUserDefaults

Build Status GitHub release Platform Version Carthage Compatible GitHub license

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

Installation

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

CocoaPods

pod 'MockUserDefaults'

Carthage (deprecated, will drop support in 2.0.0)

github "417-72KI/MockUserDefaults"

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

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.