xctruntimeassertions

XCTest extensions to test runtime assertions and preconditions

https://github.com/stanfordbdhg/xctruntimeassertions

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.1%) to scientific vocabulary

Keywords

assertion fatalerror precondition runtime stanford swift test xcode xctest
Last synced: 6 months ago · JSON representation ·

Repository

XCTest extensions to test runtime assertions and preconditions

Basic Info
Statistics
  • Stars: 2
  • Watchers: 12
  • Forks: 2
  • Open Issues: 3
  • Releases: 16
Topics
assertion fatalerror precondition runtime stanford swift test xcode xctest
Created almost 3 years ago · Last pushed 6 months ago
Metadata Files
Readme License Citation

README.md

RuntimeAssertions

Build and Test codecov DOI

Test assertions and preconditions.

Overview

This library provides the necessary runtime support to support unit testing assertions and preconditions. The library overloads Swifts runtime assertions: * assert(_:_:file:line:) * assertionFailure(_:file:line:) * precondition(_:_:file:line:) * preconditionFailure(_:file:line:)

Always call this method in your System under Test. Only if requested within a unit test, their implementations are swapped to assert a runtime assertion. Release builds will completely optimize out this runtime support library and direct calls to the original Swift implementation.

Configure your System under Test

To configure your System under Test, you just need to import the RuntimeAssertion library and call your runtime assertions functions as usual.

```swift import RuntimeAssertions

func foo() { precondition(someFooCondition, "Foo condition is unmet.") // ... } ```

Testing Runtime Assertions

In your unit tests you can use the expectRuntimeAssertion(expectedCount:_:assertion:sourceLocation:_:) and expectRuntimePrecondition(timeout:_:precondition:sourceLocation:_:) functions to test a block of code for which you expect a runtime assertion to occur.

Below is a short code example demonstrating this for assertions:

```swift import RuntimeAssertionsTesting import Testing

@Test func testAssertion() { expectRuntimeAssertion { // code containing a call to assert() of the runtime support ... } } ```

Below is a short code example demonstrating this for preconditions:

```swift import RuntimeAssertionsTesting import Testing

@Test func testPrecondition() { expectRuntimePrecondition { // code containing a call to precondition() of the runtime support ... } } ```

Tip: Both expectation methods also support the execution of async code.

Import the RuntimeAssertionsTesting module if you use Swift Testing; import XCTRuntimeAssertions if you use XCTest.

Important: Don't import RuntimeAssertionsTesting or XCTRuntimeAssertions in your application target.

Contributing

Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first.

License

This project is licensed under the MIT License. See Licenses for more information.

Stanford Byers Center for Biodesign Logo Stanford Byers Center for Biodesign Logo

Owner

  • Name: Stanford Biodesign Digital Health
  • Login: StanfordBDHG
  • Kind: organization
  • Location: United States of America

Citation (CITATION.cff)

#
# This source file is part of the Stanford RuntimeAssertions open-source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
# SPDX-License-Identifier: MIT
# 

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Schmiedmayer"
  given-names: "Paul"
  orcid: "https://orcid.org/0000-0002-8607-9148"
- family-names: "Bauer"
  given-names: "Andreas"
  orcid: "https://orcid.org/0000-0002-1680-237X"
doi: 10.5281/zenodo.7800545
title: "XCTRuntimeAssertions"
url: "https://github.com/StanfordBDHG/XCTRuntimeAssertions"

GitHub Events

Total
  • Create event: 7
  • Release event: 4
  • Issues event: 1
  • Watch event: 1
  • Delete event: 5
  • Issue comment event: 10
  • Member event: 2
  • Push event: 30
  • Pull request review comment event: 10
  • Pull request review event: 14
  • Pull request event: 5
  • Fork event: 1
Last Year
  • Create event: 7
  • Release event: 4
  • Issues event: 1
  • Watch event: 1
  • Delete event: 5
  • Issue comment event: 10
  • Member event: 2
  • Push event: 30
  • Pull request review comment event: 10
  • Pull request review event: 14
  • Pull request event: 5
  • Fork event: 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 2
  • Total pull requests: 17
  • Average time to close issues: N/A
  • Average time to close pull requests: 1 day
  • Total issue authors: 2
  • Total pull request authors: 3
  • Average comments per issue: 1.0
  • Average comments per pull request: 1.53
  • Merged pull requests: 17
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: 4 days
  • Issue authors: 1
  • Pull request authors: 2
  • Average comments per issue: 0.0
  • Average comments per pull request: 3.0
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • philippzagar (1)
  • Supereg (1)
Pull Request Authors
  • Supereg (15)
  • PSchmiedmayer (6)
  • lukaskollmer (2)
Top Labels
Issue Labels
enhancement (1) good first issue (1) bug (1)
Pull Request Labels
enhancement (9) bug (2)

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 2
  • Total dependent repositories: 6
  • Total versions: 16
swiftpackageindex.com: github.com/StanfordBDHG/XCTRuntimeAssertions

XCTest extensions to test runtime assertions and preconditions

  • Versions: 16
  • Dependent Packages: 2
  • Dependent Repositories: 6
Rankings
Dependent packages count: 4.9%
Dependent repos count: 6.4%
Average: 37.1%
Forks count: 60.6%
Stargazers count: 76.7%
Last synced: 6 months ago

Dependencies

.github/workflows/build-and-test.yml actions
.github/workflows/pull_request.yml actions
Package.swift swiftpm