diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index b46d577..ed7e251 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1,13 @@ -github: danielsaidi +# These are supported funding model platforms + +github: [danielsaidi] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8c29c49 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,34 @@ +# This workflow builds and tests the project. +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift + +name: Build Runner + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +env: + SCHEME: MockingKit + +jobs: + build: + runs-on: macos-13 + steps: + - uses: actions/checkout@v3 + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '15.1.0' + - name: Build iOS + run: xcodebuild -scheme $SCHEME -derivedDataPath .build -destination 'generic/platform=iOS'; + - name: Build macOS + run: xcodebuild -scheme $SCHEME -derivedDataPath .build -destination 'generic/platform=OS X'; + - name: Build tvOS + run: xcodebuild -scheme $SCHEME -derivedDataPath .build -destination 'generic/platform=tvOS'; + - name: Build watchOS + run: xcodebuild -scheme $SCHEME -derivedDataPath .build -destination 'generic/platform=watchOS'; + - name: Build visionOS + run: xcodebuild -scheme $SCHEME -derivedDataPath .build -destination 'generic/platform=xrOS'; + - name: Test iOS + run: xcodebuild test -scheme $SCHEME -derivedDataPath .build -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' -enableCodeCoverage YES; diff --git a/.github/workflows/docc.yml b/.github/workflows/docc.yml new file mode 100644 index 0000000..77c1244 --- /dev/null +++ b/.github/workflows/docc.yml @@ -0,0 +1,57 @@ +# This workflow builds publish DocC docs to GitHub Pages. +# Source: https://maxxfrazer.medium.com/deploying-docc-with-github-actions-218c5ca6cad5 +# Sample: https://github.com/AgoraIO-Community/VideoUIKit-iOS/blob/main/.github/workflows/deploy_docs.yml + +name: DocC Runner + +on: + push: + branches: ["main"] + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: macos-13 + steps: + - name: Checkout + uses: actions/checkout@v3 + - id: pages + name: Setup Pages + uses: actions/configure-pages@v4 + - name: Select Xcode 15.1 + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '15.1.0' + - name: Build DocC + run: | + swift package resolve; + + xcodebuild docbuild -scheme MockingKit -derivedDataPath /tmp/docbuild -destination 'generic/platform=iOS'; + + $(xcrun --find docc) process-archive \ + transform-for-static-hosting /tmp/docbuild/Build/Products/Debug-iphoneos/MockingKit.doccarchive \ + --output-path docs \ + --hosting-base-path 'MockingKit'; + + echo "" > docs/index.html; + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: 'docs' + - id: deployment + name: Deploy to GitHub Pages + uses: actions/deploy-pages@v4 diff --git a/Fastlane/Fastfile b/Fastlane/Fastfile index 678750d..313a192 100644 --- a/Fastlane/Fastfile +++ b/Fastlane/Fastfile @@ -5,9 +5,23 @@ default_platform :ios platform :ios do - library_name = "MockingKit" + name = "MockingKit" main_branch = "master" - build_folder_docs = ".build/docs" + + + # Build ================== + + lane :build do |options| + platform = options[:platform] + sh("cd .. && xcodebuild -scheme " + name + " -derivedDataPath .build -destination 'generic/platform=" + platform + "';") + end + + + # Test ================== + + lane :test_ios do + sh("cd .. && xcodebuild test -scheme " + name + " -derivedDataPath .build -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' -enableCodeCoverage YES;") + end # Version ================ @@ -15,13 +29,9 @@ platform :ios do desc "Create a new version" lane :version do |options| version_validate - docc - - bump_type = options[:type] - version = version_bump_podspec( - path: 'Version', - bump_type: bump_type) + type = options[:type] + version = version_bump_podspec(path: 'Version', bump_type: type) git_commit(path: "*", message: "Bump to #{version}") add_git_tag(tag: version) push_git_tags() @@ -33,55 +43,12 @@ platform :ios do ensure_git_status_clean ensure_git_branch(branch: main_branch) swiftlint(strict: true) - sh("swift test") - end - - - # Docs ======================= - - desc "Build documentation for all platforms" - lane :docc do - sh('cd .. && rm -rf ' + build_folder_docs) - - docc_platform(destination: 'iOS', name: 'ios') - docc_platform(destination: 'OS X', name: 'osx') - docc_platform(destination: 'tvOS', name: 'tvos') - docc_platform(destination: 'watchOS', name: 'watchos') - - docc_web_platform(name: 'ios') - docc_web_platform(name: 'osx') - docc_web_platform(name: 'tvos') - docc_web_platform(name: 'watchos') - end - - desc "Build documentation for a single platform" - lane :docc_platform do |values| - sh('cd .. && mkdir -p ' + build_folder_docs) - docc_delete_derived_data(lib: library_name) - sh('cd .. && xcodebuild docbuild \ - -scheme ' + library_name + ' \ - -destination \'generic/platform=' + values[:destination] + '\'') - sh('cd .. && \ - find ~/Library/Developer/Xcode/DerivedData \ - -name "' + library_name + '.doccarchive" \ - -exec cp -R {} ' + build_folder_docs + ' \;') - sh('cd .. && \ - mv ' + build_folder_docs + '/' + library_name + '.doccarchive ' + build_folder_docs + '/' + library_name + '_' + values[:name] + '.doccarchive') - end - - desc "Delete documentation derived data (may be historic duplicates)" - lane :docc_delete_derived_data do - sh('find ~/Library/Developer/Xcode/DerivedData \ - -name "' + library_name + '.doccarchive" \ - -exec rm -Rf {} \; || true') - end - - desc "Build static documentation website for a single platform" - lane :docc_web_platform do |values| - sh('cd .. && $(xcrun --find docc) process-archive \ - transform-for-static-hosting ' + build_folder_docs + '/' + library_name + '_' + values[:name] + '.doccarchive \ - --output-path ' + build_folder_docs + '/web_' + values[:name] + ' \ - --hosting-base-path ' + library_name + '') + build(platform: "iOS") + build(platform: "OS X") + build(platform: "tvOS") + build(platform: "watchOS") + build(platform: "xrOS") + test_ios end end diff --git a/LICENSE b/LICENSE index 650a135..8b13a5b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Daniel Saidi +Copyright (c) 2019-2024 Daniel Saidi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 3b57f2a..b662b98 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,18 @@

Version Swift 5.9 - Swift UI MIT License Twitter: @danielsaidi Mastodon: @danielsaidi@mastodon.social

+ ## About MockingKit -MockingKit lets you mock protocols and classes in `Swift`. This is useful when unit testing, or to fake functionality that is not yet implemented. +MockingKit is a Swift SDK that lets you easily mock protocols and classes in `Swift`. -MockingKit lets you create mocks of any protocol or open class, after which you can `call` functions, `register` results, `record` method invocations, and `inspect` recorded calls. +MockingKit lets you create mocks of any protocol or class, after which you can `call` functions, `register` dynamic function results, automatically `record` method invocations, and `inspect` all recorded calls. MockingKit doesn't require any setup or build scripts, and puts no restrictions on your code or architecture. Just create a mock and you're good to go. @@ -30,8 +30,6 @@ MockingKit can be installed with the Swift Package Manager: https://github.com/danielsaidi/MockingKit.git ``` -If you prefer to not have external dependencies, you can also just copy the source code into your app. - ## Getting started @@ -78,26 +76,9 @@ let result = mock.doStuff(int: 42, string: "string") // => "gnirts" // You can now inspect calls made to doStuff let calls = mock.calls(to: \.doStuffRef) // => 1 item -calls[0].arguments.0 // => 42 -calls[0].arguments.1 // => "string" +calls[0].arguments // => (42, "string") calls[0].result // => "gnirts" mock.hasCalled(\.doStuffRef) // => true -mock.hasCalled(\.doStuffRef, numberOfTimes: 1) // => true -mock.hasCalled(\.doStuffRef, numberOfTimes: 2) // => false -``` - -To mock a class, you just have to subclass the class and implement the `Mockable` protocol: - -```swift -import MockingKit - -class MockUserDefaults: UserDefaults, Mockable { - - // You must provide a mock when implementing Mockable - var mock = Mock() - - // You can now create lazy references just like in the protocol mock above -} ``` For more information, please see the [getting started guide][Getting-Started]. @@ -106,19 +87,22 @@ For more information, please see the [getting started guide][Getting-Started]. ## Documentation -The [online documentation][Documentation] has more information, code examples, etc. +The [online documentation][Documentation] has more information, articles, code examples, etc. ## Demo Application -The demo app lets you explore the library on iOS and macOS. To try it out, just open and run the `Demo` project. +The demo app lets you explore the library. To try it out, just open and run the `Demo` project. ## Support my work -You can [sponsor me][Sponsors] on GitHub Sponsors or [reach out][Email] for paid support, to help support my [open-source projects][GitHub]. +You can [sponsor me][Sponsors] on GitHub Sponsors or [reach out][Email] for paid support, to help support my [open-source projects][OpenSource]. + +Your support makes it possible for me to put more work into these projects and make them the best they can be. + @@ -140,12 +124,15 @@ MockingKit is available under the MIT license. See the [LICENSE][License] file f [Email]: mailto:daniel.saidi@gmail.com + [Website]: https://www.danielsaidi.com [GitHub]: https://www.github.com/danielsaidi [Twitter]: https://www.twitter.com/danielsaidi [Mastodon]: https://mastodon.social/@danielsaidi +[OpenSource]: https://danielsaidi.com/opensource [Sponsors]: https://github.com/sponsors/danielsaidi -[Documentation]: https://danielsaidi.github.io/MockingKit/documentation/mockingkit/ +[Documentation]: https://danielsaidi.github.io/MockingKit [Getting-Started]: https://danielsaidi.github.io/MockingKit/documentation/mockingkit/getting-started + [License]: https://github.com/danielsaidi/MockingKit/blob/master/LICENSE diff --git a/Sources/MockingKit/AsyncMockReference.swift b/Sources/MockingKit/AsyncMockReference.swift index 0e9858c..5daca6a 100644 --- a/Sources/MockingKit/AsyncMockReference.swift +++ b/Sources/MockingKit/AsyncMockReference.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Tobias Boogh on 2022-05-04. -// Copyright © 2022 Daniel Saidi. All rights reserved. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Sources/MockingKit/Mock.swift b/Sources/MockingKit/Mock.swift index b84f3a3..a5bccdf 100644 --- a/Sources/MockingKit/Mock.swift +++ b/Sources/MockingKit/Mock.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2019-04-16. -// Copyright © 2019 Daniel Saidi. All rights reserved. +// Copyright © 2019-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Sources/MockingKit/MockCall.swift b/Sources/MockingKit/MockCall.swift index 22ccb22..8b19ef3 100644 --- a/Sources/MockingKit/MockCall.swift +++ b/Sources/MockingKit/MockCall.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2019-11-11. -// Copyright © 2019 Daniel Saidi. All rights reserved. +// Copyright © 2019-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Sources/MockingKit/MockReference.swift b/Sources/MockingKit/MockReference.swift index 8b8e845..b506d72 100644 --- a/Sources/MockingKit/MockReference.swift +++ b/Sources/MockingKit/MockReference.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2020-07-16. -// Copyright © 2020 Daniel Saidi. All rights reserved. +// Copyright © 2020-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Sources/MockingKit/Mockable+Call.swift b/Sources/MockingKit/Mockable+Call.swift index 5fba2c9..99da969 100644 --- a/Sources/MockingKit/Mockable+Call.swift +++ b/Sources/MockingKit/Mockable+Call.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2019-11-25. -// Copyright © 2019 Daniel Saidi. All rights reserved. +// Copyright © 2019-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Sources/MockingKit/Mockable+Inspect.swift b/Sources/MockingKit/Mockable+Inspect.swift index 2fa188e..8aa7c9c 100644 --- a/Sources/MockingKit/Mockable+Inspect.swift +++ b/Sources/MockingKit/Mockable+Inspect.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2019-11-25. -// Copyright © 2019 Daniel Saidi. All rights reserved. +// Copyright © 2019-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Sources/MockingKit/Mockable+Register.swift b/Sources/MockingKit/Mockable+Register.swift index 05f81f8..f73c150 100644 --- a/Sources/MockingKit/Mockable+Register.swift +++ b/Sources/MockingKit/Mockable+Register.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2019-11-25. -// Copyright © 2019 Daniel Saidi. All rights reserved. +// Copyright © 2019-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Sources/MockingKit/Mockable+Reset.swift b/Sources/MockingKit/Mockable+Reset.swift index d7ce64d..9e35fec 100644 --- a/Sources/MockingKit/Mockable+Reset.swift +++ b/Sources/MockingKit/Mockable+Reset.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2019-11-25. -// Copyright © 2019 Daniel Saidi. All rights reserved. +// Copyright © 2019-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Sources/MockingKit/Mockable.swift b/Sources/MockingKit/Mockable.swift index fbe4f03..02355e5 100644 --- a/Sources/MockingKit/Mockable.swift +++ b/Sources/MockingKit/Mockable.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2019-11-25. -// Copyright © 2019 Daniel Saidi. All rights reserved. +// Copyright © 2019-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Sources/MockingKit/MockingKit.docc/Getting-Started.md b/Sources/MockingKit/MockingKit.docc/Getting-Started.md index 2d90e69..27ee09f 100644 --- a/Sources/MockingKit/MockingKit.docc/Getting-Started.md +++ b/Sources/MockingKit/MockingKit.docc/Getting-Started.md @@ -1,17 +1,28 @@ # Getting started -This article describes how you get started with MockingKit. +This article explains how to get started with MockingKit. + +@Metadata { + + @PageImage( + purpose: card, + source: "Page", + alt: "Page icon" + ) + + @PageColor(blue) +} ## Terminology -Before we continue, let's clarify some terms: +Before we start, let's clarify some terms: -* `Mock` is a simulated object that mimic the behaviour of real objects in controlled ways. -* `Mocking` is to use configurable and inspectable functionality, for instance in unit tests. -* `Registration` is to register return values for a mock function, based on its input arguments. -* `Call/Invoke` is to call a function in a way that records the call, its arguments, the result, etc. -* `Inspection` is to inspect the recorded calls, e.g. to verify that a function has been called, with what arguments, etc. +* **Mock** is a simulated object that mimic the behaviour of real objects in controlled ways. +* **Mocking** is to use configurable and inspectable functionality, for instance in unit tests. +* **Call/Invoke** is calling a function in a way that records the call and its arguments & result. +* **Registration** is to register dynamic return values for a mock function, based on its arguments. +* **Inspection** is to inspect a recorded call, e.g. to verify that it has been called, its arguments, etc. Let's have a look at how this works in MockingKit. @@ -19,7 +30,7 @@ Let's have a look at how this works in MockingKit. ## Creating a mock -MockingKit lets you create mocks of any protocol or open class, after which you can `call` functions, `register` results, `record` method invocations, and `inspect` recorded calls. +MockingKit lets you mock any protocol or open class, after which you can **call** functions, **register** results, **record** method invocations, and **inspect** recorded calls. For instance, consider this simple protocol: @@ -47,7 +58,7 @@ class MyMock: Mock, MyProtocol { } ``` -To mock a class, you just have to subclass the class and implement the ``Mockable`` protocol: +To mock a class, you instead have to subclass the class and implement the ``Mockable`` protocol: ```swift import MockingKit @@ -61,37 +72,17 @@ class MockUserDefaults: UserDefaults, Mockable { } ``` -``Mock`` is actually just a ``Mockable`` that returns itself as the ``Mockable/mock``. +``Mock`` is actually just a ``Mockable`` that returns itself as its ``Mockable/mock``. -With a mock in place, you can now start mocking functionality in your unit tests or app. +With the mock in place, you can now start mocking functionality in your unit tests or app. ## Using the mock -You can now use the mock to `register` function results, `call` functions and `inspect` recorded calls. +We can now use the mock to register dynamic function results, call mocked functions and inspect all recorded calls. -```swift -// Create a mock -let mock = MyMock() - -// Register a doStuff result -mock.registerResult(for: mock.doStuffRef) { args in String(args.1.reversed()) } - -// Calling doStuff will now return the pre-registered result -let result = mock.doStuff(int: 42, string: "string") // => "gnirts" - -// You can now inspect calls made to doStuff -let calls = mock.calls(to: mock.doStuffRef) // => 1 item -calls[0].arguments.0 // => 42 -calls[0].arguments.1 // => "string" -calls[0].result // => "gnirts" -mock.hasCalled(mock.doStuffRef) // => true -mock.hasCalled(mock.doStuffRef, numberOfTimes: 1) // => true -mock.hasCalled(mock.doStuffRef, numberOfTimes: 2) // => false -``` - -For more compact code, you can use keypaths: +The easiest and most compact way to do this is to use keypaths: ```swift // Create a mock @@ -117,60 +108,70 @@ You can configure the mock in any way you want to change the behavior of your te -## Important about registering mock function return values +## Important about registering return values -There are some things to consider regarding function return values: +There are some things to consider when registering mock function return values: -* If a function return value is non-optional, you must register a return value before calling the function. Calling it before registering a return value will cause a crash. -* If a function return value is optional, registering a return value is optional. Calling the function before registering a return value will just return nil and not crash. +* **Optional** functions will return **nil** if you don't register a return value before calling them. +* **Non-optional** functions will **crash** if you don't register a return value before calling them. -You can register new return values at any time, for instance to try many different variations within the same test. +You can register new return values at any time, for instance to try many different return values within the same test or test case. ## Multiple function arguments -Since mock arguments are handled as tuples, inspection behaves a bit different if a mocked function has multiple arguments. +Since mock function arguments are handled as tuples, inspection behaves a bit different if a mocked function has multiple arguments. -For instance, consider a protocol that looks like this: +For instance, consider this protocol: ```swift protocol MyProtocol { - func doStuff(int: Int, string: String) -> String + func one(_ int: Int) -> String + func two(_ int: Int, _ string: String) -> String } ``` -A MockingKit mock would look like this: +A MockingKit mock of this protocol could look like this: ```swift class MyMock: Mock, MyProtocol { - lazy var doStuffRef = MockReference(doStuff) + lazy var oneRef = MockReference(one) + lazy var twoRef = MockReference(two) - func doStuff(int: Int, string: String) -> String { - call(doStuffRef, args: (int, string)) + func one(_ int: Int) -> String { + call(oneRef, args: (int, string)) + } + + func two(_ int: Int, _ string: String) -> String { + call(oneRef, args: (int, string)) } } ``` -Since arguments are handled as tuples, you must then use tuple positions to inspect them: +Functions with a single argument can inspect the argument directly, while functions with two or more arguments require inspecting the arguments as tuples: ```swift let mock = MyMock() -mock.registerResult(for: mock.doStuffRef) { args in String(args.1.reversed()) } -let result = mock.doStuff(int: 42, string: "string") // => "gnirts" -let inv = mock.invokations(of: mock.doStuffRef) // => 1 item -inv[0].arguments.0 // => 42 -inv[0].arguments.1 // => "message" +mock.registerResult(for: mock.oneRef) { args in -args } +mock.registerResult(for: mock.twoRef) { args in String(args.1.reversed()) } +let res1 = mock.one(int: 1) // => -1 +let res2 = mock.two(int: 2, string: "string") // => "gnirts" +let inv1 = mock.calls(to: mock.oneRef) // => 1 item +let inv2 = mock.calls(to: mock.twoRef) // => 1 item +inv1[0].arguments // => -1 +inv2[0].arguments.0 // => 2 +inv2[0].arguments.1 // => "message" ``` -There is no upper-limit to the number of function arguments you can use in a mocked function. +There is no upper-limit to the number of arguments you can use in a mocked function. ## Multiple functions with the same name -Mock references require some extra considerations when a mock has multiple functions with the same name. +Mocked function references require some considerations when protocol or class has multiple functions with the same name. For instance, consider a protocol that looks like this: @@ -200,7 +201,7 @@ class MyMock: Mock, MyProtocol { } ``` -This gives you a unique references for every unique function. +This gives you a unique references for each function, which you can use just like above. The rest works exactly the same. @@ -224,6 +225,4 @@ Mocking `async` functions works exactly like mocking non-async functions. No add Functions with completion blocks are just `Void` functions where the completion block is just an argument. -Mocking these kind of functions works exactly like mocking any other functions. No additional code is required. - -You must however manually call the completion from within your mock, if you want them to trigger. +Mocking these kind of functions works exactly like mocking any other functions. No additional code is required. diff --git a/Sources/MockingKit/MockingKit.docc/MockingKit.md b/Sources/MockingKit/MockingKit.docc/MockingKit.md index 8fb2c71..c510b58 100644 --- a/Sources/MockingKit/MockingKit.docc/MockingKit.md +++ b/Sources/MockingKit/MockingKit.docc/MockingKit.md @@ -1,6 +1,6 @@ # ``MockingKit`` -MockingKit lets you mock protocols and classes in `Swift`. +MockingKit is a Swift SDK that lets you easily mock protocols and classes in `Swift`. @@ -8,9 +8,9 @@ MockingKit lets you mock protocols and classes in `Swift`. ![MockingKit logo](Logo.png) -Mockinging is useful when unit testing, or to fake functionality that is not yet implemented. +MockingKit is a Swift SDK that lets you easily mock protocols and classes in `Swift`. -MockingKit lets you create mocks of any protocol or open class, after which you can `call` functions, `register` results, `record` method invocations, and `inspect` recorded calls. +MockingKit lets you create mocks of any protocol or class, after which you can `call` functions, `register` dynamic function results, automatically `record` method invocations, and `inspect` all recorded calls. MockingKit doesn't require any setup or build scripts, and puts no restrictions on your code or architecture. Just create a mock and you're good to go. @@ -24,25 +24,23 @@ MockingKit can be installed with the Swift Package Manager: https://github.com/danielsaidi/MockingKit.git ``` -If you prefer to not have external dependencies, you can also just copy the source code into your app. - ## Getting started -The article helps you get started with ApiKit. +The article helps you get started with MockingKit. ## Repository -For more information, source code, etc., visit the [project repository][Repository]. +For more information, source code, etc., visit the [project repository](https://github.com/danielsaidi/MockingKit). ## License -ApiKit is available under the MIT license. See the [LICENSE][License] file for more info. +ApiKit is available under the MIT license. @@ -66,8 +64,3 @@ ApiKit is available under the MIT license. See the [LICENSE][License] file for m - ``MockPasteboard`` - ``MockTextDocumentProxy`` - ``MockUserDefaults`` - - - -[License]: https://github.com/danielsaidi/MockingKit/blob/master/LICENSE -[Repository]: https://github.com/danielsaidi/MockingKit diff --git a/Sources/MockingKit/MockingKit.docc/Resources/Page.png b/Sources/MockingKit/MockingKit.docc/Resources/Page.png new file mode 100644 index 0000000..eb12a41 Binary files /dev/null and b/Sources/MockingKit/MockingKit.docc/Resources/Page.png differ diff --git a/Sources/MockingKit/Mocks/MockNotificationCenter.swift b/Sources/MockingKit/Mocks/MockNotificationCenter.swift index 23e144f..5d01405 100644 --- a/Sources/MockingKit/Mocks/MockNotificationCenter.swift +++ b/Sources/MockingKit/Mocks/MockNotificationCenter.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2020-08-03. -// Copyright © 2020 Daniel Saidi. All rights reserved. +// Copyright © 2020-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Sources/MockingKit/Mocks/MockPasteboard.swift b/Sources/MockingKit/Mocks/MockPasteboard.swift index f787ac2..28a6bf2 100644 --- a/Sources/MockingKit/Mocks/MockPasteboard.swift +++ b/Sources/MockingKit/Mocks/MockPasteboard.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2019-05-28. -// Copyright © 2021 Daniel Saidi. All rights reserved. +// Copyright © 2021-2024 Daniel Saidi. All rights reserved. // #if os(iOS) diff --git a/Sources/MockingKit/Mocks/MockTextDocumentProxy.swift b/Sources/MockingKit/Mocks/MockTextDocumentProxy.swift index ed964f4..b89d4dd 100644 --- a/Sources/MockingKit/Mocks/MockTextDocumentProxy.swift +++ b/Sources/MockingKit/Mocks/MockTextDocumentProxy.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2019-07-04. -// Copyright © 2021 Daniel Saidi. All rights reserved. +// Copyright © 2021-2024 Daniel Saidi. All rights reserved. // #if os(iOS) diff --git a/Sources/MockingKit/Mocks/MockUserDefaults.swift b/Sources/MockingKit/Mocks/MockUserDefaults.swift index 9cdc547..4488238 100644 --- a/Sources/MockingKit/Mocks/MockUserDefaults.swift +++ b/Sources/MockingKit/Mocks/MockUserDefaults.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2020-07-17. -// Copyright © 2020 Daniel Saidi. All rights reserved. +// Copyright © 2020-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Tests/MockingKitTests/Foundation/MockNotificationCenterTests.swift b/Tests/MockingKitTests/Foundation/MockNotificationCenterTests.swift index 12f02c9..1506f2a 100644 --- a/Tests/MockingKitTests/Foundation/MockNotificationCenterTests.swift +++ b/Tests/MockingKitTests/Foundation/MockNotificationCenterTests.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2020-08-03. -// Copyright © 2020 Daniel Saidi. All rights reserved. +// Copyright © 2020-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Tests/MockingKitTests/Foundation/MockUserDefaultsTests.swift b/Tests/MockingKitTests/Foundation/MockUserDefaultsTests.swift index 9d5b866..0dffe4a 100644 --- a/Tests/MockingKitTests/Foundation/MockUserDefaultsTests.swift +++ b/Tests/MockingKitTests/Foundation/MockUserDefaultsTests.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2020-07-17. -// Copyright © 2020 Daniel Saidi. All rights reserved. +// Copyright © 2020-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Tests/MockingKitTests/GenericTests.swift b/Tests/MockingKitTests/GenericTests.swift index 3f8f970..acdff5c 100644 --- a/Tests/MockingKitTests/GenericTests.swift +++ b/Tests/MockingKitTests/GenericTests.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2020-07-17. -// Copyright © 2020 Daniel Saidi. All rights reserved. +// Copyright © 2020-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Tests/MockingKitTests/MockableAsyncTests.swift b/Tests/MockingKitTests/MockableAsyncTests.swift index 23f7fb4..6aafe6d 100644 --- a/Tests/MockingKitTests/MockableAsyncTests.swift +++ b/Tests/MockingKitTests/MockableAsyncTests.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Tobias Boogh on 2022-05-04. -// Copyright © 2022 Daniel Saidi. All rights reserved. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. // import XCTest diff --git a/Tests/MockingKitTests/MockableTests.swift b/Tests/MockingKitTests/MockableTests.swift index 4705369..74463f3 100644 --- a/Tests/MockingKitTests/MockableTests.swift +++ b/Tests/MockingKitTests/MockableTests.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2019-11-25. -// Copyright © 2020 Daniel Saidi. All rights reserved. +// Copyright © 2020-2024 Daniel Saidi. All rights reserved. // import XCTest diff --git a/Tests/MockingKitTests/TestTypes.swift b/Tests/MockingKitTests/TestTypes.swift index b293986..ec7296b 100644 --- a/Tests/MockingKitTests/TestTypes.swift +++ b/Tests/MockingKitTests/TestTypes.swift @@ -3,7 +3,7 @@ // MockingKit // // Created by Daniel Saidi on 2019-04-16. -// Copyright © 2019 Daniel Saidi. All rights reserved. +// Copyright © 2019-2024 Daniel Saidi. All rights reserved. // import Foundation