Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/artem-y/swifty-test-assertions
Lightweight addition of useful assertions to XCTest
https://github.com/artem-y/swifty-test-assertions
ios macos swift testing-tools tvos unit-testing visionos watchos xctest
Last synced: 13 days ago
JSON representation
Lightweight addition of useful assertions to XCTest
- Host: GitHub
- URL: https://github.com/artem-y/swifty-test-assertions
- Owner: artem-y
- License: mit
- Created: 2023-11-16T00:18:30.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-01-06T10:07:01.000Z (10 months ago)
- Last Synced: 2024-07-30T20:59:25.508Z (3 months ago)
- Topics: ios, macos, swift, testing-tools, tvos, unit-testing, visionos, watchos, xctest
- Language: Swift
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwiftyTestAssertions
Lightweight addition of useful assertions to XCTestI've been using these assertions in different projects for a while and they proved quite handy, so I decided to move them to separate package. It is important that this package only contains the actual assertions without extra noise, to make it small and easy to add.
### Installation
#### In Swift package:
1. Add `swifty-test-assertions` to package dependencies in `Package.swift`:
```swift
.package(url: "[email protected]:artem-y/swifty-test-assertions.git", from: "0.1.1"),
```
2. Add `SwiftyTestAssertions` product dependency to test target(s) in `Package.swift`:
```swift
.product(name: "SwiftyTestAssertions", package: "swifty-test-assertions"),
```
3. Import `SwiftyTestAssertions` module where they need to be used:
```swift
import SwiftyTestAssertions
```
#### In Xcode project/workspace:
1. Go to File > Add Package Dependencies... in Xcode top navigation menu.
- _or go to project settings "Package Dependencies" and hit "+"_
- _or go to "General" target settings tab, in target's "Frameworks and Settings" section choose "+", then select "Add Package Dependency..."_
3. Search for `artem-y/swifty-test-assertions` (paste this link into search):```swift
[email protected]:artem-y/swifty-test-assertions.git
```
4. When Xcode finds the package, select "Up to Next Major Version" dependency rule and press "Add Package" button
5. Choose a test target that needs to use this package and press "Add Package"
6. Import `SwiftyTestAssertions` module where they need to be used:
```swift
import SwiftyTestAssertions
```
### Examples
```swift
Assert(
try sut.validate(colorHex: "ABCXYZ"), // tested expression
throwsError: ArgumentValidator.ColorHexError.hasInvalidSymbols // check if this exact error is thrown
)
```
More code examples using these helpers can be found in [examples-of-swifty-test-assertions](https://github.com/artem-y/examples-of-swifty-test-assertions) repository. They are kept there separately to make this library as lightweight as possible.