generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Add XCTAssertThrowsErrorAsync ## ♻️ Current situation & Problem This PR adds a async version of the [`XCTAssertThrowsError(_:_:file:line:_:)`](https://developer.apple.com/documentation/xctest/1500795-xctassertthrowserror) method. This method was originally introduced in SpeziBluetooth but was now found to be useful as well in SpeziDevices. Therefore, there is a need to have this available as a reusable implementation. ## ⚙️ Release Notes * Add `XCTAssertThrowsErrorAsync(_:_:file:line:_:)` method. ## 📚 Documentation New interfaces were documented. Additionally the documentation catalog was restructured to provide a bit more overview of supported types. ## ✅ Testing Minimal testing. ### Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
- Loading branch information
Showing
8 changed files
with
114 additions
and
22 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
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,19 @@ | ||
# | ||
# This source file is part of the Stanford Spezi open source project | ||
# | ||
# SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
|
||
name: Monthly Markdown Link Check | ||
|
||
on: | ||
# Runs at midnight on the first of every month | ||
schedule: | ||
- cron: "0 0 1 * *" | ||
|
||
jobs: | ||
markdown_link_check: | ||
name: Markdown Link Check | ||
uses: StanfordBDHG/.github/.github/workflows/markdown-link-check.yml@v2 |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// This source file is part of the Stanford XCTestExtensions open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import XCTest | ||
|
||
|
||
/// Asserts that an async expression throws an error. | ||
/// | ||
/// - Note: This is an async version of [`XCTAssertThrowsError(_:_:file:line:_:)`](https://developer.apple.com/documentation/xctest/1500795-xctassertthrowserror). | ||
/// | ||
/// - Parameters: | ||
/// - expression: An async expression that can throw an error. | ||
/// - message: An optional description of a failure. | ||
/// - file: The file where the failure occurs. The default is the filename of the test case where you call this function. | ||
/// - line: The line number where the failure occurs. The default is the line number where you call this function. | ||
/// - errorHandler: An optional handler for errors that expression throws. | ||
public func XCTAssertThrowsErrorAsync<T>( | ||
_ expression: @autoclosure () async throws -> T, | ||
_ message: @autoclosure () -> String = "", | ||
file: StaticString = #filePath, | ||
line: UInt = #line, | ||
_ errorHandler: (Error) throws -> Void = { _ in } | ||
) async rethrows { | ||
do { | ||
_ = try await expression() | ||
XCTFail(message(), file: file, line: line) | ||
} catch { | ||
try errorHandler(error) | ||
} | ||
} |
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