-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08d6af9
commit 1c8ba57
Showing
28 changed files
with
224 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "<script>window.location.href += \"/documentation/mockingkit\"</script>" > 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,18 +5,18 @@ | |
<p align="center"> | ||
<img src="https://img.shields.io/github/v/release/danielsaidi/MockingKit?color=%2300550&sort=semver" alt="Version" /> | ||
<img src="https://img.shields.io/badge/Swift-5.9-orange.svg" alt="Swift 5.9" /> | ||
<img src="https://img.shields.io/badge/platform-SwiftUI-blue.svg" alt="Swift UI" title="Swift UI" /> | ||
<img src="https://img.shields.io/github/license/danielsaidi/MockingKit" alt="MIT License" /> | ||
<a href="https://twitter.com/danielsaidi"><img src="https://img.shields.io/twitter/url?label=Twitter&style=social&url=https%3A%2F%2Ftwitter.com%2Fdanielsaidi" alt="Twitter: @danielsaidi" title="Twitter: @danielsaidi" /></a> | ||
<a href="https://mastodon.social/@danielsaidi"><img src="https://img.shields.io/mastodon/follow/000253346?label=mastodon&style=social" alt="Mastodon: @[email protected]" title="Mastodon: @[email protected]" /></a> | ||
</p> | ||
|
||
|
||
|
||
## 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:[email protected] | ||
|
||
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.